用ASP自动清空IE缓存里的内容
来源:互联网 责任编辑:栏目编辑 发表时间:2013-07-02 03:06 点击:次
有时候缓存会给程序带来很大的麻烦,这段代码是用来清空IE缓存里的内容
1.禁止客户端缓存要在<head>中加入类似如下内):
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> |
2.在服务器的动态网页中禁止缓存,要加入类似如下脚本
(1)asp:
<% Response.Expires = -1 Response.ExpiresAbsolute = Now() - 1 Response.cachecontrol = "no-cache" %> 或者 <% pStr = "private, no-cache, must-revalidate" Response.ExpiresAbsolute = date() Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", pStr %> |
(2)jsp:
response.setHeader("Pragma","No-cache"); response.setHeader("Cache-Control","no-cache"); response.setDateHeader("Expires", 0); |