清除Tomcat中的JSP页面缓存有如下两个方法:
一、清除页面缓存在jsp页里
<%response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
response.flushBuffer();%>
3.document.write("<script src='test.js?rnd="+Math.random()+"'></s"+"cript>")。
(2)删除work目录下的缓存文件。
在html页里
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
二、清除cookie
<%
Cookie killMyCookie = new Cookie("mycookie", null);
killMyCookie.setMaxAge(0);
killMyCookie.setPath("/");
response.addCookie(killMyCookie);
%>
三、清除session清除session方法<%@ page language="java" %>
<%
session.invalidate();
%> 在页面关闭时清除session,需要捕获windows.onclose事件,再调用清除session方法
火狐浏览器中,清除缓存:
<%
response.setHeader( "Pragma", "No-Cache ");
response.setHeader( "Cache-Control", "No-Cache");
response.setDateHeader( "Expires",0);
<meta http-equiv="cache-control" content="no-store, must-revalidate"/>