我使用apache2作为loadbalancer,在tomcat服务器前面使用frontend-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,但是没有用。
有什么想法吗?
发布于 2016-08-21 01:52:47
当Magnolia返回资源并希望通知浏览器不应缓存该资源时,它设置了几个标头:pragma: no-cache、cache-control: no-store和Expires: 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标头,但不缓存任何其他内容。
https://stackoverflow.com/questions/39015105
复制相似问题