nginx_compression
This is an old revision of the document!
Nginx Site Compression
Adding compressions can significantly reduce the size of the data transmitted.
Note: since compressions happens at run time it can add considerable processing overhead which can in turn cause negative performance.
Note2: Some clients do not support responses with gzip encoding method. To successfully server both clients that do and do no accept compressed data, nginx can decompress data on the fily when sending it to a client that does not support compression
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types
text/plain
text/css
application/json
application/x-javascript
text/xml application/xml
application/xml+rss
text/javascript;
| Value | Description |
|---|---|
| gzip on | turns on compressions |
| gzip_proxied | By default, NGINX does not compress responses to proxied requests (requests that come from the proxy server). The fact that a request comes from a proxy server is determined by the presence of the Via header field in the request. To configure compression of these responses, use the gzip_proxied directive. The directive has a number of parameters specifying which kinds of proxied requests NGINX should compress |
| gzip_types | By default, NGINX compresses responses only with MIME type text/html |
Testing Compression
Has your compression been configured correctly?
https://gtmetrix.com/
nginx_compression.1455990718.txt.gz · Last modified: 2024/05/23 07:26 (external edit)
