您好,登錄后才能下訂單哦!
1、作用
節(jié)約帶寬,額外消耗CPU;部分老瀏覽器不支持;
壓縮適于壓縮的資源,例如文本文件;
2、涉及模塊
LoadModule deflate_module modules/mod_deflate.so(CentOS6默認(rèn)啟用)
3、配置(httpd-2.2)
~]# vim /etc/httpd/conf.d/mod_deflate.conf
輸入以下代碼
SetOutputFilter DEFLATE # 設(shè)置壓縮過(guò)濾器,指明哪些類型適合壓縮 # 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 # 壓縮級(jí)別根據(jù)CPU消耗和帶寬來(lái)決定,6為默認(rèn) # 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、確認(rèn)壓縮效果
配置前
配置后
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。