方法一:
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
//or response.setHeader("Cache-Control","no-store");//HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
方法二:
import java.text.SimpleDateFormat;
import java.util.Date;
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy - HH:mm:ss z");
response.setHeader("Expires", dateFormat.format(new Date()));
方法三:
关于IE缓存的解决方案禁止服务器端缓存:Response.Expires = 0 或
禁用客户端缓存。
HTM网页:
ASP网页:
<% Response.Expires = -1 Response.ExpiresAbsolute = Now() - 1 Response.cachecontrol = "no-cache" %>PHP网页:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache");JSP:
response.setHeader("Pragma","No-Cache"); response.setHeader("Cache-Control","No-Cache"); response.setDateHeader("Expires", 0);C#中禁止cache的方法:
Response.Buffer=true; Response.ExpiresAbsolute=System.DateTime.Now.AddSeconds(-1); Response.Expires=0; Response.CacheControl="no-cache";