适用场景
- 节约带宽,额外消耗CPU;同时,可能有些较老浏览器不支持;
- 压缩适于压缩的资源,例如文本文件;
设置过滤器
vim /etc/httpd/conf.d/compress.conf
SetOutputFilter DEFLATE #名字可以自定义
# mod_deflate configuration
# Restrict compression to these MIME types
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE applicatioin/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
# Level of compression(Highest 9 - Lowest 1)
DeflateCompressionLevel 9
#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 \bMSI[E] !no-gzip !gzip-only-text/html
网友评论