[英]Prevent browser caching with an ASP.NET OutputCacheProvider
I'm using a System.Web.Caching.OutputCacheProvider. 我正在使用System.Web.Caching.OutputCacheProvider。 I do not want browsers to cache, I only want to do server caching.
我不想浏览器缓存,我只想做服务器缓存。 I see that when something comes out of my server cache, they get an Expires header of 24 hours in the future.
我看到当服务器缓存中出现某些内容时,它们将在未来24小时内获得Expires标头。 How do I modify this?
我该如何修改?
Calling HttpContext.Current.Response.Cache.SetExpires() in my Get() method doesn't have an effect and neither does changing HTTP Response Headers->Set Common Headers->Expire Web content in IIS. 在我的Get()方法中调用HttpContext.Current.Response.Cache.SetExpires()无效,并且在IIS中更改HTTP响应标头->设置公共标头->过期Web内容也无效。
You can use the Location attribute for OutputCache attribute. 您可以将Location属性用于OutputCache属性。 For Asp.Net Web Pages
对于Asp.Net网页
<%@ OutputCache Location="Server" ...%>
For Asp.Net MVC 对于Asp.Net MVC
[OutputCache(Location=OutputCacheLocation.Server)]
After that the classic Response.Expires = 0
approach should be enough (if necessary) to prevent browser caching. 之后,经典的
Response.Expires = 0
方法应足以防止浏览器缓存(如有必要)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.