(1)作用
? 使用mod_deflate模塊壓縮頁面優(yōu)化傳輸速度
? 適用場景:
(1) 節(jié)約帶寬荞估,額外消耗CPU嘱兼;同時成艘,可能有些較老瀏覽器不支持
(2) 壓縮適于壓縮的資源爪飘,例如文本文件
LoadModule deflate_module modules/mod_deflate.so
SetOutputFilter DEFLATE
\# 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 application/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 只壓縮text/html
BrowserMatch ^Mozilla/4 gzip-only-text/html
Netscape 4.06-08三個版本 不壓縮
BrowserMatch ^Mozilla/4.0[678] no-gzip
Internet Explorer標(biāo)識本身為“Mozilla / 4”砌左,但實際上是能夠處理請求的壓縮脖咐。如果用戶代理首部匹配字符串“MSIE”(“B”為單詞邊界”),就關(guān)閉之前定義的限制
BrowserMatch \bMSI[E] !no-gzip !gzip-onlytext/html