mod_cache返回“broken expires header”

时间:2016-08-18 09:52:16

标签: tomcat caching apache2 magnolia ajp

我在tomcat服务器前面使用apache2作为loadbalancerfrontend-proxy,通过mod_ajp连接。现在,我想添加缓存。

不幸的是,tomcat服务器的应用程序发回了很多头文件,根据RFC,它会阻止像pragma: no-cache这样的缓存等。但主要问题是错误信息:

HTTP/1.1 200 OK
Date: Thu, 18 Aug 2016 09:44:33 GMT
Server: Apache/2.4.10 (Debian)
X-Magnolia-Registration: Registered
Set-Cookie: JSESSIONID=xxxxxxx; Path=/form-cms/; Secure; HttpOnly
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Content-Encoding: gzip
Vary: Accept-Encoding
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Last-Modified: Thu, 18 Aug 2016 09:44:33 GMT
Content-Language: en
X-Cache: MISS from fqdn.example.com
X-Cache-Detail: "Broken expires header: Thu, 01 Jan 1970 00:00:00 GMT" from fqdn.example.com
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html;charset=UTF-8

缓存配置如下所示:

CacheRoot "/var/cache/apache2/mod_cache_disk"
CacheDirLevels 2
CacheDirLength 1
CacheMaxExpire 60
CacheDefaultExpire 60

CacheHeader on
CacheDetailHeader on

CacheIgnoreHeaders Expires
CacheIgnoreCacheControl on

CacheStoreNoStore On
CacheStorePrivat On

CacheQuickHandler off
<LocationMatch "^/my-app/.*">
    CacheEnable disk
</LocationMatch>

我对如何解决此问题感到茫然,并且无法在tomcat服务器上更改应用程序的行为。我试图通过mod_headers取消设置expires-header,但无济于事。

任何想法?

1 个答案:

答案 0 :(得分:1)

当Magnolia返回资源并希望通知浏览器时,它不应该被缓存,而是设置了几个标题:pragma: no-cachecache-control: no-storeExpires: Thu, 01 Jan 1970 00:00:00 GMT标题

由于第一个unix时间戳是01/01/1970 12:00:00 am,mod_cache apache模块确实发出broken expires header消息。

解决方案是更改Magnolia的BrowserPolicy设置以包含FixedDuration expires标头,但不要缓存任何其他内容。