HttpGzipModule
(→Directives) |
(→Directives) |
||
| Line 15: | Line 15: | ||
= Directives = | = Directives = | ||
== gzip == | == gzip == | ||
| − | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/ngx_http_gzip_module/gzip.txt" /> | + | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_gzip_module/gzip.txt" /> |
Enables or disables gzip compression. | Enables or disables gzip compression. | ||
== gzip_buffers == | == gzip_buffers == | ||
| − | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/ngx_http_gzip_module/gzip_buffers.txt" /> | + | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_gzip_module/gzip_buffers.txt" /> |
Assigns the number and the size of the buffers into which to store the compressed response. If unset, the size of one buffer is equal to the size of page, depending on platform this either 4K or 8K. | Assigns the number and the size of the buffers into which to store the compressed response. If unset, the size of one buffer is equal to the size of page, depending on platform this either 4K or 8K. | ||
| Line 26: | Line 26: | ||
== gzip_comp_level == | == gzip_comp_level == | ||
| − | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/ngx_http_gzip_module/gzip_comp_level.txt" /> | + | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_gzip_module/gzip_comp_level.txt" /> |
The compression level, between 1 and 9, where 1 is the least compression (fastest) and 9 is the most (slowest). | The compression level, between 1 and 9, where 1 is the least compression (fastest) and 9 is the most (slowest). | ||
| Line 32: | Line 32: | ||
== gzip_disable == | == gzip_disable == | ||
| − | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/ngx_http_gzip_module/gzip_disable.txt" /> | + | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_gzip_module/gzip_disable.txt" /> |
Disable gzip compression for User-Agents matching the given regular expression. Requires PCRE library. Introduced in Nginx 0.6.23. | Disable gzip compression for User-Agents matching the given regular expression. Requires PCRE library. Introduced in Nginx 0.6.23. | ||
| Line 44: | Line 44: | ||
== gzip_http_version == | == gzip_http_version == | ||
| − | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/ngx_http_gzip_module/gzip_http_version.txt" /> | + | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_gzip_module/gzip_http_version.txt" /> |
Turns gzip compression on or off depending on the HTTP request version. | Turns gzip compression on or off depending on the HTTP request version. | ||
| Line 52: | Line 52: | ||
== gzip_min_length == | == gzip_min_length == | ||
| − | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/ngx_http_gzip_module/gzip_min_length.txt" /> | + | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_gzip_module/gzip_min_length.txt" /> |
Sets the minimum length, in bytes, of the response that will be compressed. Responses shorter than this byte-length will not be compressed. Length is determined from the "Content-Length" header. | Sets the minimum length, in bytes, of the response that will be compressed. Responses shorter than this byte-length will not be compressed. Length is determined from the "Content-Length" header. | ||
| Line 58: | Line 58: | ||
== gzip_proxied == | == gzip_proxied == | ||
| − | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/ngx_http_gzip_module/gzip_proxied.txt" /> | + | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_gzip_module/gzip_proxied.txt" /> |
It allows or disallows the compression of the response for the proxy request in the dependence on the request and the response. The fact that, request proxy, is determined on the basis of line "Via" in the headers of request. In the directive it is possible to indicate simultaneously several parameters: | It allows or disallows the compression of the response for the proxy request in the dependence on the request and the response. The fact that, request proxy, is determined on the basis of line "Via" in the headers of request. In the directive it is possible to indicate simultaneously several parameters: | ||
| Line 73: | Line 73: | ||
== gzip_types == | == gzip_types == | ||
| − | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/ngx_http_gzip_module/gzip_types.txt" /> | + | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_gzip_module/gzip_types.txt" /> |
Enables compression for additional MIME-types besides "text/html". "text/html" is always compressed. | Enables compression for additional MIME-types besides "text/html". "text/html" is always compressed. | ||
== gzip_vary == | == gzip_vary == | ||
| − | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/ngx_http_gzip_module/gzip_vary.txt" /> | + | <include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_gzip_module/gzip_vary.txt" /> |
Enables response header of "Vary: Accept-Encoding". Note that this header causes IE 4-6 not to cache the content due to a bug (see [http://marc.info/?l=apache-modgzip&m=103921021108395&w=2] ). | Enables response header of "Vary: Accept-Encoding". Note that this header causes IE 4-6 not to cache the content due to a bug (see [http://marc.info/?l=apache-modgzip&m=103921021108395&w=2] ). | ||
Revision as of 19:31, 2 May 2012
Contents |
Synopsis
This module allows for on-the-fly gzip compression. See also Gzip pre-compression module .
Example
gzip on; gzip_min_length 1000; gzip_proxied expired no-cache no-store private auth; gzip_types text/plain application/xml; gzip_disable "MSIE [1-6]\.";
Compression ratio is available via the variable $gzip_ratio.
Directives
gzip
| Syntax: |
gzip on | off |
| Default: | off |
| Context: |
http server location if in location |
| Reference: | gzip |
Enables or disables gzip compression.
gzip_buffers
| Syntax: | gzip_buffers number size |
| Default: | 32 4k|16 8k |
| Context: |
http server location |
| Reference: | gzip_buffers |
Assigns the number and the size of the buffers into which to store the compressed response. If unset, the size of one buffer is equal to the size of page, depending on platform this either 4K or 8K.
gzip_comp_level
| Syntax: | gzip_comp_level level |
| Default: | 1 |
| Context: |
http server location |
| Reference: | gzip_comp_level |
The compression level, between 1 and 9, where 1 is the least compression (fastest) and 9 is the most (slowest).
gzip_disable
| Syntax: | gzip_disable regex ... |
| Default: | |
| Context: |
http server location |
| Appeared in: | 0.6.23 |
| Reference: | gzip_disable |
Disable gzip compression for User-Agents matching the given regular expression. Requires PCRE library. Introduced in Nginx 0.6.23.
You can use "msie6" to disable gzip for Internet Explorer 5.5 and Internet Explorer 6. "SV1" (Service Pack 2) will be ignored since Nginx 0.7.63.
Example
gzip_disable "msie6";
gzip_http_version
| Syntax: |
gzip_http_version 1.0 | 1.1 |
| Default: | 1.1 |
| Context: |
http server location |
| Reference: | gzip_http_version |
Turns gzip compression on or off depending on the HTTP request version.
When HTTP version 1.0 is used, the Vary: Accept-Encoding header is not set. As this can lead to proxy cache corruption, consider adding it with add_header . Also note that the Content-Length header is not set when using either version. Keepalives will therefore be impossible with version 1.0, while for 1.1 it is handled by chunked transfers.
gzip_min_length
| Syntax: | gzip_min_length length |
| Default: | 20 |
| Context: |
http server location |
| Reference: | gzip_min_length |
Sets the minimum length, in bytes, of the response that will be compressed. Responses shorter than this byte-length will not be compressed. Length is determined from the "Content-Length" header.
gzip_proxied
| Syntax: |
gzip_proxied off | expired | no-cache | no-store | private | no_last_modified | no_etag | auth | any ... |
| Default: | off |
| Context: |
http server location |
| Reference: | gzip_proxied |
It allows or disallows the compression of the response for the proxy request in the dependence on the request and the response. The fact that, request proxy, is determined on the basis of line "Via" in the headers of request. In the directive it is possible to indicate simultaneously several parameters:
- off - disables compression for all proxied requests
- expired - enables compression, if the "Expires" header prevents caching
- no-cache - enables compression if "Cache-Control" header is set to "no-cache"
- no-store - enables compression if "Cache-Control" header is set to "no-store"
- private - enables compression if "Cache-Control" header is set to "private"
- no_last_modified - enables compression if "Last-Modified" isn't set
- no_etag - enables compression if there is no "ETag" header
- auth - enables compression if there is an "Authorization" header
- any - enables compression for all requests
gzip_types
| Syntax: | gzip_types mime-type ... |
| Default: | text/html |
| Context: |
http server location |
| Reference: | gzip_types |
Enables compression for additional MIME-types besides "text/html". "text/html" is always compressed.
gzip_vary
| Syntax: |
gzip_vary on | off |
| Default: | off |
| Context: |
http server location |
| Reference: | gzip_vary |
Enables response header of "Vary: Accept-Encoding". Note that this header causes IE 4-6 not to cache the content due to a bug (see [1] ).










