0
好吧,所以我的nocache過濾器似乎不工作。我讀過其他的stackoverflow問題,但他們的答案似乎並沒有工作。我使用的是Firefox。嘗試清除緩存,重新啓動tomcat。過濾器也被調用,並且標題顯示頁面不被高速緩存。但當我點擊後退按鈕頁面仍然加載..該怎麼辦?從高速緩存停止jsp頁面
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
HttpServletResponse httpResponse = (HttpServletResponse) response;
HttpServletRequest httpRequest = (HttpServletRequest) request;
// Set standard HTTP/1.1 no-cache headers.
httpResponse.setHeader("Cache-Control", "private, no-store, no-cache, must-revalidate");
// Set standard HTTP/1.0 no-cache header.
httpResponse.setHeader("Pragma", "no-cache");
httpResponse.setDateHeader("Expires", 0); //prevents caching at the proxy server
String method = httpRequest.getMethod();
String URI = httpRequest.getRequestURI();
System.out.println(method + " request invoked on " + URI);
chain.doFilter(httpRequest, httpResponse);
}
編輯:我也沒有嘗試把< meta>標記,沒有好..
是否過濾器映射所有的網址? – 2015-01-06 21:19:12