(1) 在jsp页面或servlet里设置(server端)
<%
// 将过期日期设置为一个过去时间
response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
// 设置 HTTP/1.1 no-cache 头
response.setHeader("Cache-Control", "no-store,no-cache,must-revalidate");
// 设置 IE 扩展 HTTP/1.1 no-cache headers, 用户自己添加
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
// 设置标准 HTTP/1.0 no-cache header.
response.setHeader("Pragma", "no-cache");
%>
(2)禁止客户端缓存要在<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">
或 <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">