一种解决方案是在URL中添加一个QueryString变量,该变量是一个随机的GUID,但这似乎有些混乱。是否有某个设置可以防止浏览器显示页面的缓存版本?
<meta http-equiv="pragma" content="no-cache" />
Public Sub DisableCaching()
With Response
.Expires = 0
.ExpiresAbsolute = Date.Today.AddDays(-1)
.AddHeader("pragma", "no-cache")
.AddHeader("cache-control", "no-cache")
End With
End Sub
一种方法是添加“过期时间或缓存控制头”。
这个方法摘自Yahoo最佳实践(http://developer.yahoo.com/performance/rules.html)
这个规则有两个要点:
* For static components: implement "Never expire" policy by setting far future Expires header
* For dynamic components: use an appropriate Cache-Control header to help the browser with conditional requests
浏览器(以及代理)使用缓存来减少HTTP请求的数量和大小,从而使网页加载更快。Web服务器使用HTTP响应中的Expires头告诉客户端可以缓存一个组件的时间有多长。这是一个远期的Expires头,告诉浏览器此响应直到2010年4月15日之前都不会过时。
Expires: Thu, 15 Apr 2010 20:00:00 GMT
ExpiresDefault "access plus 10 years"
试试以下任何一种方法:
Response.Cache.SetExpires(DateTime.Now.AddSeconds(360));
Response.Cache.SetCacheability(HttpCacheability.Private)
Response.Cache.SetSlidingExpiration(true);
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)
Also see this question.