Apache的mod_cache和mod_deflate?

我们有一个Apache 2.2与mod_cache和mod_deflate等模块。 问题是如果我们在Apache文档中添加Vary头文件…

# Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary 

…我们最终得到了caching中每个用户代理变体的服务资源的副本。 这浪费了磁盘空间并降低了命中率。

那么,这个问题的首选解决scheme是什么? 沟Vary头和只压缩“安全”的资源,如纯HTML?

将用户代理设置为不同的头部的原因是,Apache推荐的mod_deflateconfiguration将一些内容的未压缩版本提供给Netscape 4用户。 现在可能Netscape 4的用户已经不多,您可以将压缩内容提供给所有声称支持它的浏览器,而不会因用户代理而异。

所以,而不是推荐的configuration:

 <Location /> # Insert filter SetOutputFilter DEFLATE # Netscape 4.x has some problems... BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI \ \.(?:gif|jpe?g|png)$ no-gzip dont-vary # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </Location> 

你可以只有:

 <Location /> # Insert filter SetOutputFilter DEFLATE # Don't compress images SetEnvIfNoCase Request_URI \ \.(?:gif|jpe?g|png)$ no-gzip dont-vary </Location>