Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux教程 >> nginx如何配置gzip壓縮

nginx如何配置gzip壓縮

日期:2017/2/7 14:41:36      編輯:Linux教程
 

gzip壓縮用的是http_gzip_module模塊.這個模塊支持在線實時壓縮輸出數據流,使用范例:
 

gzip             on;
 gzip_min_length  1000;
 gzip_proxied     expired no-cache no-store private auth;
gzip_types       text/plain application/x-javascript text/css text/html application/xml;


gzip on|off
開啟或者關閉gzip模塊
gzip_min_length 1000
設置允許壓縮的頁面最小字節數,頁面字節數從header頭中的Content-Length中進行獲取。
默認值是0,不管頁面多大都壓縮。
建議設置成大於1k的字節數,小於1k可能會越壓越大。 即: gzip_min_length 1024
gzip_proxied expired no-cache no-store private auth;
Nginx作為反向代理的時候啟用,開啟或者關閉後端服務器返回的結果,匹配的前提是後端服務器必須要返回包含”Via”的 header頭。
gzip_types text/plain application/xml;
匹配MIME類型進行壓縮,(無論是否指定)”text/html”類型總是會被壓縮的。

Copyright © Windows教程網 All Rights Reserved