如何使页面不被浏览器Cache保留

来源:互联网 发布:大数据采集工具 编辑:程序博客网 时间:2024/05/17 02:23
方法一
<%
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())); 
 
 
方法三
<meta http-equiv='Expires' content='-10'>
<meta http-equiv='Pragma'  content='No-cache'>
<meta http-equiv='Cache-Control', 'private'>