代码之家  ›  专栏  ›  技术社区  ›  Paul W Homer

如何防止上下文中的Tomcat部署文件在浏览器中缓存?

  •  0
  • Paul W Homer  · 技术社区  · 16 年前

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>GeneralRequests</web-resource-name>
            <url-pattern>/WR1/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
    

    在最近对IE6的测试中,我们发现“有时”页面会缓存,尽管我们还没有完全确定何时缓存。除了机密标志外,我们还曾经有:

            response.setHeader("Pragma", "No-cache");
            response.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
            response.setDateHeader("Expires", 1);
    

    更新: 我们检查了一下,Tomcat正确发送了Pragma、Cache Control和Expires参数,所以这不是问题所在(好吧,没有发送字符串和最大年龄值,但仍然不是问题所在)。

    1 回复  |  直到 16 年前
        1
  •  1
  •   banjollity    16 年前

    response.setHeader("Expires", 0);