ChsHttpGzipModule
Nginx涓枃鏂囨。 > 鍩烘湰妯″潡 > ngx_http_gzip_module
杩欎釜妯″潡鏀寔鍦ㄧ嚎瀹炴椂鍘嬬缉杈撳嚭鏁版嵁娴
__浣跨敤鑼冧緥__
: gzip on; : gzip_min_length 1000; : gzip_proxied expired no-cache no-store private auth; : gzip_types text/plain application/xml;
鍐呯疆鍙橀噺 $gzip_ratio 鍙互鑾峰彇鍒癵zip鐨勫帇缂╂瘮鐜
Contents |
鎸囦护
- [#gzip gzip]
- [#gzip_buffers gzip_buffers]
- [#gzip_comp_level gzip_comp_level]
- [#gzip_min_length gzip_min_length]
- [#gzip_http_version gzip_http_version]
- [#gzip_proxied gzip_proxied]
- [#gzip_types gzip_types]
gzip
璇硶: gzip on|off
榛樿鍊: gzip off
浣滅敤鍩: http, server, location, if (x) location
寮鍚垨鑰呭叧闂璯zip妯″潡
gzip_buffers
璇硶: gzip_buffers number size
榛樿鍊: gzip_buffers 4 4k/8k
浣滅敤鍩: http, server, location
璁剧疆绯荤粺鑾峰彇鍑犱釜鍗曚綅鐨勭紦瀛樼敤浜庡瓨鍌╣zip鐨勫帇缂╃粨鏋滄暟鎹祦銆
渚嬪
4 4k 浠h〃浠4k涓哄崟浣嶏紝鎸夌収鍘熷鏁版嵁澶у皬浠4k涓哄崟浣嶇殑4鍊嶇敵璇峰唴瀛樸
4 8k 浠h〃浠8k涓哄崟浣嶏紝鎸夌収鍘熷鏁版嵁澶у皬浠8k涓哄崟浣嶇殑4鍊嶇敵璇峰唴瀛樸
濡傛灉娌℃湁璁剧疆锛岄粯璁ゅ兼槸鐢宠璺熷師濮嬫暟鎹浉鍚屽ぇ灏忕殑鍐呭瓨绌洪棿鍘诲瓨鍌╣zip鍘嬬缉缁撴灉銆
gzip_comp_level
璇硶: gzip_comp_level 1..9
榛樿鍊: gzip_comp_level 1
浣滅敤鍩: http, server, location
gzip鍘嬬缉姣旓紝1 鍘嬬缉姣旀渶灏忓鐞嗛熷害鏈蹇紝9 鍘嬬缉姣旀渶澶т絾澶勭悊鏈鎱紙浼犺緭蹇絾姣旇緝娑堣梒pu锛夈
gzip_min_length
璇硶: gzip_min_length length
榛樿鍊: gzip_min_length 0
浣滅敤鍩: http, server, location
璁剧疆鍏佽鍘嬬缉鐨勯〉闈㈡渶灏忓瓧鑺傛暟锛岄〉闈㈠瓧鑺傛暟浠巋eader澶翠腑鐨凜ontent-Length涓繘琛岃幏鍙栥
榛樿鍊兼槸0锛屼笉绠¢〉闈㈠澶ч兘鍘嬬缉銆
寤鸿璁剧疆鎴愬ぇ浜1k鐨勫瓧鑺傛暟锛屽皬浜1k鍙兘浼氳秺鍘嬭秺澶с 鍗: gzip_min_length 1024
gzip_http_version
璇硶: gzip_http_version 1.0|1.1
榛樿鍊: gzip_http_version 1.1
浣滅敤鍩: http, server, location
璇嗗埆http鐨勫崗璁増鏈傜敱浜庢棭鏈熺殑涓浜涙祻瑙堝櫒鎴栬卙ttp瀹㈡埛绔紝鍙兘涓嶆敮鎸乬zip鑷В鍘嬶紝鐢ㄦ埛灏变細鐪嬪埌涔辩爜锛屾墍浠ュ仛涓浜涘垽鏂繕鏄湁蹇呰鐨勩 娉細21涓栫邯閮芥潵浜嗭紝鐜板湪闄や簡绫讳技浜庣櫨搴︾殑铚樿洓涔嬬被鐨勪笢瑗夸笉鏀寔鑷В鍘嬶紝99.99%鐨勬祻瑙堝櫒鍩烘湰涓婇兘鏀寔gzip瑙e帇浜嗭紝鎵浠ュ彲浠ヤ笉鐢ㄨ杩欎釜鍊,淇濇寔绯荤粺榛樿鍗冲彲銆
gzip_proxied
璇硶: gzip_proxied [off|expired|no-cache|no-store|private|no_last_modified|no_etag|auth|any] ...
榛樿鍊: gzip_proxied off
浣滅敤鍩: http, server, location
Nginx浣滀负鍙嶅悜浠g悊鐨勬椂鍊欏惎鐢紝寮鍚垨鑰呭叧闂悗绔湇鍔″櫒杩斿洖鐨勭粨鏋滐紝鍖归厤鐨勫墠鎻愭槸鍚庣鏈嶅姟鍣ㄥ繀椤昏杩斿洖鍖呭惈"Via"鐨 header澶淬
- off - 鍏抽棴鎵鏈夌殑浠g悊缁撴灉鏁版嵁鐨勫帇缂
- expired - 鍚敤鍘嬬缉锛屽鏋渉eader澶翠腑鍖呭惈 "Expires" 澶翠俊鎭
- no-cache - 鍚敤鍘嬬缉锛屽鏋渉eader澶翠腑鍖呭惈 "Cache-Control:no-cache" 澶翠俊鎭
- no-store - 鍚敤鍘嬬缉锛屽鏋渉eader澶翠腑鍖呭惈 "Cache-Control:no-store" 澶翠俊鎭
- private - 鍚敤鍘嬬缉锛屽鏋渉eader澶翠腑鍖呭惈 "Cache-Control:private" 澶翠俊鎭
- no_last_modified - 鍚敤鍘嬬缉,濡傛灉header澶翠腑涓嶅寘鍚 "Last-Modified" 澶翠俊鎭
- no_etag - 鍚敤鍘嬬缉 ,濡傛灉header澶翠腑涓嶅寘鍚 "ETag" 澶翠俊鎭
- auth - 鍚敤鍘嬬缉 , 濡傛灉header澶翠腑鍖呭惈 "Authorization" 澶翠俊鎭
- any - 鏃犳潯浠跺惎鐢ㄥ帇缂
gzip_types
璇硶: gzip_types mime-type [mime-type ...]
榛樿鍊: gzip_types text/html
浣滅敤鍩: http, server, location
鍖归厤MIME绫诲瀷杩涜鍘嬬缉锛岋紙鏃犺鏄惁鎸囧畾锛"text/html"绫诲瀷鎬绘槸浼氳鍘嬬缉鐨勩
娉ㄦ剰锛氬鏋滀綔涓篽ttp server鏉ヤ娇鐢紝涓婚厤缃枃浠朵腑瑕佸寘鍚枃浠剁被鍨嬮厤缃枃浠
http { include conf/mime.types; ...... }
濡傛灉浣犲笇鏈涘帇缂╁父瑙勭殑鏂囦欢绫诲瀷锛屽彲浠ュ啓鎴愯繖涓牱瀛
http { : include conf/mime.types; : gzip on; : gzip_min_length 1000; : gzip_buffers 4 8k; : gzip_http_version 1.1; : gzip_types text/plain application/x-javascript text/css text/html application/xml; : ...... }