日期:2014-05-16  浏览次数:20895 次

ASP页面存在缓存如何清除?
后台页面

主要是信息列表页缓存比较严重,只要页面被访问过。下次再进来,就还是访问的老页面,即使数据库中更新过数据。也不会更新。非要强刷一下才可以显示。


页面的头部加了禁止缓存的语句,

Response.AddHeader "Progma","no-cache"
Response.AddHeader "Cache-Control","no-cache"
Response.Expires = 0

或者写成 Response.Expires = Now()-1 也还是一样。


如何解决这个问题?如何强制客户端重新从服务端读取最新信息?
我知道在地址后面加随机数可以解决这个问题。但是页面的操作比较多。不可能全部加随机数,有没有其它的办法?这缓存严重影响使用啊。
------解决方案--------------------
Sub noCache()
Response.Buffer = True
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.CacheControl = "no-cache"
Response.AddHeader "Expires",Date()
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "Cache-Control","private, no-cache, must-revalidate"
Session.CodePage=65001
Response.Charset="utf-8"
End Sub

在页面开始调用这个过程
------解决方案--------------------
访问信息列表网页时在URL后加时间戳:
location.ref="list.php?"+New Date().getTime();
------解决方案--------------------
每次的url,加个uuid进去。保证不同的url,就可以拿到最新的内容了。
------解决方案--------------------
location.ref="list.php?r="+Math.random();