您好,登錄后才能下訂單哦!
1、作用
節約帶寬,額外消耗CPU;部分老瀏覽器不支持;
壓縮適于壓縮的資源,例如文本文件;
2、涉及模塊
LoadModule deflate_module modules/mod_deflate.so(CentOS6默認啟用)
3、配置(httpd-2.2)
~]# vim /etc/httpd/conf.d/mod_deflate.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 application/xml AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/css # Level of compression(Highest 9 - Lowest 1) DeflateCompressionLevel 6 # 壓縮級別根據CPU消耗和帶寬來決定,6為默認 # 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
~]# httpd -t ~]# service httpd reload
4、確認壓縮效果
配置前
配置后
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。