简体   繁体   English

Tomcat和缓存控制:私有,并且到期: <date in past> -这是哪里?

[英]Tomcat and cache-control: Private, and Expires: <date in past> - Where is this set?

In the response header of all requests, there is a cache-control: private , and Expires that is set. 在所有请求的响应标头中,设置了一个缓存控件:private和Expires。 I'd like to know where this is set. 我想知道在哪里设置。

I have the following setup: 1. F5 load balanced to two CentOS 6.4 servers hosting Tomcat 7.0.42.0 2. I've set an ExpiresFilter for images, css and js files. 我有以下设置:1. F5负载均衡到托管Tomcat 7.0.42.0的两台CentOS 6.4服务器上。2.我为图像,css和js文件设置了ExpiresFilter。 However, these types are not always cached. 但是,这些类型并不总是被缓存。

There are two environments , however only 1 of the environments is showing the response header Cache-Control private, and Expires Wed, 31 Dec 1969 19:00:00 EST. 有两种环境,但是只有一种环境显示响应头Cache-Control private和Expires Wed,1969年12月31日,美国东部时间。 The other env does not show this. 另一个env没有显示此内容。

I've done a diff of the server.xml, web.xml and context.xml of Tomcat, and there are no major differences. 我已经完成了Tomcat的server.xml,web.xml和context.xml的区别,并且没有重大区别。

Googling results in some posts related to SSL config, but I cant figure what exactly the issue is. 谷歌搜索导致一些与SSL配置相关的帖子,但我无法弄清楚问题到底出在哪里。

Response header with cache-control and expires in the past: 具有缓存控制的响应头,它在过去过期:

    Cache-Control   private
    Content-Length  0
    Date    Fri, 06 Mar 2015 16:08:16 GMT
    Expires Wed, 31 Dec 1969 19:00:00 EST
    Location    https://myhost.com/mypage
    Response    HTTP/1.1 302 Found
    Server  Apache-Coyote/1.1

I had exactly the same problem. 我有完全一样的问题。 My tomcat installation has custom [web.xml] and [conf.xml] files at conf folder, to serve HTTPS connections. 我的tomcat安装在conf文件夹中具有自定义的[web.xml]和[conf.xml]文件,用于提供HTTPS连接。 In my case, the problem was with a HTTPS security constraint inside [conf.xml] file: 以我为例,问题出在[conf.xml]文件中的HTTPS安全约束:

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

This constraint force clients to use always HTTPS, even with port 80 opened. 此约束迫使客户端即使在端口80打开的情况下也始终使用HTTPS。 Once this contraint was removed from web.xml, cache began to work ("cache-control" header with "max-age", and "expires" with the correct date). 从web.xml中删除此约束后,缓存开始工作(带有“ max-age”的“ cache-control”标头和具有正确日期的“ expires”)。

Found a resolution to the issue, but not the exact cause. 找到了解决问题的方法,但没有找到确切的原因。

I installed a new instance of tomcat on the same host, but in another directory, and this resolved the header 'Expires Wed, 31 Dec 1969 19:00:00 EST' and 'Cache-Control private'. 我在同一台主机上但在另一个目录中安装了一个新的tomcat实例,这解决了标头“ Expires Wed,31 Dec 1969 19:00:00 EST”和“ Cache-Control private”。 Also copied over the tomcat-users.xml, server.xml, and web.xml from the previous Tomcat installation of the same host. 还从同一主机的先前Tomcat安装中的tomcat-users.xml,server.xml和web.xml复制。

I suspect there were some leftover config somewhere from the removal of the Apache Web Server on the original installation that was causing the issue. 我怀疑是在导致问题的原始安装上删除了Apache Web Server之后,仍有一些剩余配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM