clarkk Asked: 2018-06-10 12:13:31 +0800 CST2018-06-10 12:13:31 +0800 CST 2018-06-10 12:13:31 +0800 CST gzip not working on nginx 772 conf gzip on; gzip_vary on; gzip_min_length 100; gzip_buffers 16 8k; gzip_proxied any; gzip_types text/plain text/css text/javascript application/json application/javascript; nginx 3 Answers Voted Best Answer Kernelv5 2018-07-28T00:23:02+08:002018-07-28T00:23:02+08:00 Make Sure Gzip module installed with nginx 2>&1 nginx -V | tr -- - '\n' | grep _module | grep gzip Output Should be : http_gzip_static_module Configuration Host Configuration file under server block. gzip on; gzip_disable "msie6"; gzip_comp_level 6; gzip_min_length 1100; gzip_buffers 16 8k; gzip_proxied any; gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/rss+xml image/svg+xml/javascript; service nginx reload Testing curl -H "Accept-Encoding: gzip" -I https://example.com/ dave 2018-07-25T23:23:27+08:002018-07-25T23:23:27+08:00 Have you tried to add 'gzip_comp_level level;'? It looks like you missed something in your configuration. Here you have a working example: gzip on; gzip_comp_level 2; gzip_http_version 1.0; gzip_proxied any; gzip_min_length 1100; gzip_buffers 16 8k; gzip_types text/plain text/html text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_disable "MSIE [1-6].(?!.*SV1)"; gzip_vary on; miknik 2018-07-23T08:30:01+08:002018-07-23T08:30:01+08:00 In my experience you can't rely on browser developer console output to check for gzip compression. Any anti virus software you have running is probably going to intercept and decompress the gzip files to scan them before they hit the browser. I have gzip enabled on my Nginx servers and I see no evidence of it in my chrome dev console. curl reveals the truth though... curl -H "Accept-Encoding: gzip" -I https://example.com/ returns: HTTP/1.1 200 OK Server: nginx Date: Sun, 22 Jul 2018 16:22:41 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Vary: Accept-Encoding Link: <https://example.com/>; rel=shortlink Access-Control-Allow-Origin: https://example.com Content-Encoding: gzip Where Content-Encoding: gzip is obviously what you are looking for in your response headers. You may also want to add a gzip_http_version 1.0; directive to your Nginx conf, as by default http 1.1 is minimum version required for Nginx to serve gzip
Make Sure Gzip module installed with nginx
Output Should be : http_gzip_static_module
Configuration
Host Configuration file under server block.
service nginx reload
Testing
Have you tried to add '
gzip_comp_level level;
'? It looks like you missed something in your configuration. Here you have a working example:In my experience you can't rely on browser developer console output to check for gzip compression.
Any anti virus software you have running is probably going to intercept and decompress the gzip files to scan them before they hit the browser.
I have gzip enabled on my Nginx servers and I see no evidence of it in my chrome dev console.
curl reveals the truth though...
curl -H "Accept-Encoding: gzip" -I https://example.com/
returns:
Where
Content-Encoding: gzip
is obviously what you are looking for in your response headers.You may also want to add a
gzip_http_version 1.0;
directive to your Nginx conf, as by default http 1.1 is minimum version required for Nginx to serve gzip