Pet*_*i H 2 http-headers mod-deflate mod-cache apache-2.2
我们有一个带有 mod_cache 和 mod_deflate 以及其他模块的 Apache 2.2。问题是,如果我们在 Apache 文档中附加 Vary 标头...
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
Run Code Online (Sandbox Code Playgroud)
...我们最终在缓存中为每个用户代理变体提供了服务资源的副本。这会浪费磁盘空间并降低命中率。
那么,这个问题的首选解决方案是什么?放弃 Vary 标头并仅压缩“安全”资源,例如纯 html?
将标头设置为因用户代理而异的原因是 Apache 推荐的 mod_deflate 配置为 Netscape 4 用户提供某些内容的未压缩版本。现在可能有足够的 Netscape 4 用户,您可以只向声称支持它的所有浏览器提供压缩内容,而不会因用户代理而异。
因此,而不是推荐的配置:
<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>
Run Code Online (Sandbox Code Playgroud)
你可以只拥有:
<Location />
# Insert filter
SetOutputFilter DEFLATE
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
</Location>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2525 次 |
最近记录: |