在 .NET Framework 4.5.1 中,可以使用以下方式设置缓存控制头:

HttpResponse response = HttpContext.Current.Response;
response.Cache.SetCacheability(HttpCacheability.NoCache);
response.Cache.AppendCacheExtension('no-store, must-revalidate');

该代码将缓存控制设置为不缓存,并添加了一些附加扩展,以确保客户端不会缓存响应。

在 .NET Framework 4.5.1 中设置 Web API 响应的缓存控制

原文地址: https://www.cveoy.top/t/topic/mxS8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录