How to control cache in JSP page?

前端 未结 4 1608
温柔的废话
温柔的废话 2020-12-16 06:44

I created a Servlet filter with the following code in doFilter:

HttpServletResponse httpResponse = (HttpServletResponse)response;

httpResponse.setHeader(\"C         


        
4条回答
  •  粉色の甜心
    2020-12-16 07:13

    We also use the Last-Modified header to encourage the browser to always get a new version.

    setDateHeader("Last-Modified", (new Date()).getTime() ); // Set last modified to right now.

    I'm not sure about keeping the browser's back button from using the cache, though. Anything that you do with header fields is only going to be evaluated when the page is first loaded, IIRC.

提交回复
热议问题