Prevent IE caching

后端 未结 5 1953
慢半拍i
慢半拍i 2020-12-23 22:39

I am developing a Java EE web application using Struts. The problem is with Internet Explorer caching. If an user logs out he can access some pages because they are cached a

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 23:11

    Rather set the following headers on the HttpServletResponse of the page(s) in question so that you don't need to copypaste it over all pages manually:

    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
    response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
    response.setDateHeader("Expires", 0); // Proxies.
    

    This is equivalent to setting the following meta headers in the page(s) manually:

    
    
    
    

    Also see this answer. Don't forget to clear browser cache before testing ;)

提交回复
热议问题