![mod_deflate 的默认配置可以在生产设置中使用吗?](https://linux22.com/image/517107/mod_deflate%20%E7%9A%84%E9%BB%98%E8%AE%A4%E9%85%8D%E7%BD%AE%E5%8F%AF%E4%BB%A5%E5%9C%A8%E7%94%9F%E4%BA%A7%E8%AE%BE%E7%BD%AE%E4%B8%AD%E4%BD%BF%E7%94%A8%E5%90%97%EF%BC%9F.png)
mod_deflate 的官方文档有效,并且到目前为止在我的服务器上取得了不错的效果。有人建议在生产机器上使用哪些更改吗?
http://httpd.apache.org/docs/2.2/mod/mod_deflate.html#recommended
<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>
答案1
您必须权衡时间和大小。如果您花时间更改压缩级别,则可能需要多花几毫秒才能提供页面,而压缩后的页面变小所带来的好处微乎其微。
默认设置相当平衡,可以正确处理 99% 的浏览器,并且经过深思熟虑。