nginx / Web Service

15.8 nginx:压缩模块(ngx_http_gzip_module)

 

压缩模块<ngx_http_gzip_module>:
=========================================

gzip:

  Syntax:	gzip on | off;
  Default:	gzip off;
  Context:	http, server, location, if in location

Enables or disables gzipping of responses;

gzip_comp_level:

  Syntax:	gzip_comp_level level;
  Default:	gzip_comp_level 1;
  Context:	http, server, location

Sets a gzip compression level of a response. Acceptable values are in the range from 1 to 9;

gzip_disable:

  Syntax:	gzip_disable regex ...;
  Default:	—
  Context:	http, server, location

Disables gzipping of responses for requests with “User-Agent” header fields matching any of the specified regular expressions.

gzip_min_length:

Syntax:		gzip_min_length length;
Default:	gzip_min_length 20;
Context:	http, server, location

压缩响应报文大小阈值;设置要压缩的响应报文的最小长度,长度仅由“Content-Length”响应头字段决定;

gzip_buffers:

Syntax:		gzip_buffers number size;
Default:	gzip_buffers 32 4k|16 8k;
Context:	http, server, location

支持实现压缩功能时,为其配置的缓冲区数量及每个缓存区的大小;

gzip_proxied:

Syntax:		gzip_proxied off | expired | no-cache | no-store | private | no_last_modified | no_etag | auth | any ...;
Default:	gzip_proxied off;
Context:	http, server, location

nginx做为代理服务器,在接收到后端服务器发送过来的响应报文后,在何种条件下启用压缩功能;
off:不启用压缩功能;
no-cache | no-store | private :表示从后端服务器收到的响应报文首部的”cach_control”的值为此三者中任意一个时,就启用压缩功能;

gzip_types:

Syntax:		gzip_types mime-type ...;
Default:	gzip_types text/html;
Context:	http, server, location

压缩过滤器,仅对此处设定的MIME类型内容启用压缩功能;

举例:

gzip  on;
gzip_comp_level  1;
gzip_types    text/css  text/xml  application/javascript;

Leave a Reply

Your email address will not be published. Required fields are marked *