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

JSP技术分享:常用禁止缓存的四种方法

【IT168?技术】以下是常用禁止缓存的四种方法:

  1、客户端缓存要在head中加入类似如下内容:

<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><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">

  或

<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">

  2、在服务器的动态网页中禁止缓存,要加入类似如下脚本:

<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->response.setHeader("Pragma","No-cache");
response.setHeader(
"Cache-Control","no-cache");
response.setDateHeader(
"Expires