强制Apache 2.4使用mod_cachecaching具有查询string的文件,而不会过期

我需要得到mod_cache_diskcaching包含查询string的网站。 问题在于,它是IIS上的一个供应商产品,我们试图通过mod_proxy进行caching,并且不包含expires头文件。 我意识到这个问题违反了几个RFC,这就是为什么Apache不默认。

有没有办法强制的Apache 2.4.xcaching与查询string,并没有过期头?

这种configuration将caching,但当然不尊重? 它caching大部分项目的错误内容。

CacheEnable disk https:// CacheEnable disk / CacheRoot /var/cache/mod_proxy/ CacheDirLevels 4 CacheDirLength 5 CacheIgnoreCacheControl On CacheIgnoreNoLastMod On CacheIgnoreHeaders None CacheMaxFileSize 100000000 CacheMinFileSize 1 CacheMaxExpire 1209600 CacheDefaultExpire 3600 CacheIgnoreQueryString On CacheStoreNoStore On CacheStorePrivate On 

如果我将CacheIgnoreQueryString更改为Off,它将开始发出关于expires标题的错误。

AH00768:caching:/view.image?Id=1114没有caching。 原因:查询string存在但没有明确的到期时间,

根据这个答案 ,唯一的办法就是让Apache看到它想要的头文件(Expires,你说过的,显然也是Last-Modified)。

这个答案的海报build议在应用程序方面写一个filter,但由于你的是一个供应商的产品,这可能是不可能的。 有没有机会直接在IIS中添加它? 否则,你可能有一个双代理设置运气:使用一个代理来添加头(而不是caching),并从Apache代理(采取头和caching)。

这是我的解决scheme

 <IfModule mod_cache.c> CacheIgnoreNoLastMod On CacheIgnoreHeaders Set-Cookie <IfModule mod_disk_cache.c> CacheRoot D:\\apache_cache CacheEnable disk / CacheDirLevels 1 CacheDirLength 1 </IfModule> </IfModule> 

并从后端添加标题

 Cache-Control:s-maxage=1200 

s-maxage – 用于代理caching和CDN

最明显的解决scheme是在查询string到达mod_cache之前将其mod_cache

最明显的模块是mod_rewrite

但是这是行不通的 ,因为mod_cache 在2006年有目的地开始使用查询string的不变版本 。