This article mainly introduces the detailed explanation of GZip configuration parameters in Nginx server, that is, using GZip to compress website page data. Friends in need can refer to it
gzip (GUN-ZIP) is a compression technology , the page size after gzip compression can be reduced to 30% or less of the original size.
Users will browse the page faster. The gzip compressed page needs to be supported by both the server and the browser. The server-side compression is transmitted to the
browser for decompression and parsing. Now most Most browsers already support parsing gzip pages
gzip usage environment: http, server, location, if (x), generally I define it in http{…..} of nginx.conf Time
gzip on;
Turn on gzip off off
gzip_min_length 1k;
Set the minimum page bytes allowed for compression ( Obtained from the Content-Length of the header header) It is recommended to be greater than 1k
gzip_buffers 4 16k;
is based on 16k as the unit, and applies for memory in 4 times the original data size in 16k as the unit
gzip_http_version 1.1;
Identify the version of http protocol. Early browsers may not support gzip self-extraction, and users will see garbled characters
gzip_comp_level 2;
Level 1-9 The smallest compression is the fastest but consumes cpu
gzip_types text/plain application/x-javascript text/css application/xml;
Match compression type
gzip_vary on;
Enable response header "Vary: Accept-Encoding"
gzip_proxied off;
Enable when nginx is used as a reverse proxy, off (turn off the compression of all proxy result data), expired (enable compression, if the header header includes "Expires" header information), no-cache (enable compression, in the header header) Contains "Cache-Control: no-cache"), no-store (enables compression, the header contains "Cache-Control: no-store"), private (enables compression, the header contains "Cache-Control: private" ), no_last_modefied (enable compression, the header does not contain "Last-Modified"), no_etag (enable compression, if the header does not contain "Etag" header information), auth (enable compression, if the header contains "Authorization" header information)
gzip_disable msie6;
(IE5.5 and IE6 SP1 use the msie6 parameter to disable gzip compression) Specify which browsers do not require gzip compression (will be used with User- Agents for matching), relying on the PCRE library
##gzip
Determine whether to enable the gzip moduleexample:
gzip on;
gzip_buffers
Set the size of memory requested by gzip. Its function is to apply for memory space in multiples of the block size. param2:int(k) The following unit is k
example:
gzip_buffers 4 8k;
gzip_comp_level
Set the gzip compression level. The lower the level, the faster the compression speed and the smaller the file compression ratio. On the contrary, the slower the speed, the larger the file compression ratio. param:1-9
example:
gzip_com_level 1;
gzip_min_length
When the returned content is greater than this value, gzip will be used for compression, in K, when the value is 0, all pages will be compressedparam:int
example:
gzip_min_length 1000;
gzip_types
Set the MIME type that needs to be compressed, non-set values will not be compressedparam:text/html|application/x-javascript|text/ css|application/xml
example:
gzip_types text/html;
How to quickly view nginx configuration files
The above is the detailed content of Analysis of GZip configuration parameters in Nginx server. For more information, please follow other related articles on the PHP Chinese website!