2014-09-24 111 views
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>标记,没有好..

+0

是否过滤器映射所有的网址? – 2015-01-06 21:19:12

回答

-1

试试下面

httpResponse.setDateHeader("Expires", -1); //Add this line 

httpResponse.setDateHeader("Expires", 0);//Remove this line 

查找详细here

+0

我也读过。试图将其更改为-1。仍然没有好处。点击后退按钮只是再次加载页面。 – Audix 2014-09-24 16:04:41