網(wǎng)站的流量是十分寶貴的資源(拿筆者的vps來說,流量都是算錢地=_=!)。如何節(jié)約這寶貴的資源,盡量減少網(wǎng)站服務(wù)器與瀏覽器之間的數(shù)據(jù)傳輸量;降低網(wǎng)站成本呢?開啟網(wǎng)頁gzip壓縮是不二之選。
gzip壓縮率比較高,能夠有效較少傳輸字節(jié)數(shù)據(jù)70%多。也不用擔(dān)心瀏覽器不支持gzip壓縮過的網(wǎng)頁。因為幾乎所有瀏覽器(95%以上)都支持解壓縮gzip網(wǎng)頁的。
本文中向各位介紹一下常用的服務(wù)器apache和nginx是如何開啟網(wǎng)頁gzip壓縮功能的,總有一款適合你^_^。
| # BEGIN GZIP #apache開啟gzip壓縮,前提要裝gzip模塊哦 <ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript </ifmodule> # END GZIP |
| #nginx開啟gzip壓縮,放在location內(nèi) gzip on; gzip_min_length 1000; gzip_buffers 4 8k; gzip_http_version 1.1; gzip_types text/text text/html text/plain text/xml text/css application/x-javascript application/javascript; |
如果你想知道gzip壓縮是否成功開始,去“站長工具”網(wǎng)自己檢測一下吧
|
新聞熱點
疑難解答