Nginx Gzip compression

demas asked:

I have Ubuntu with Nginx installed. I have not deploy any site and just GET default Nginx static page.

Here is Nginx settings:

# Gzip Settings

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
gzip_comp_level 4;
# 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;

I am checking compression using (my site to test and it say that the response is not compressed.

Google Developers Tools says:

enter image description here

Why the compression does not work ?



Full Nginx configuration:

My answer:

On testing your site, I find that the response is compressed with gzip.

Your screenshot shows a cached response. Clear your browser cache and try again.

As for the tool, the reason it is not getting a compressed response is that it sent an HTTP/1.0 request to your server, rather than an HTTP/1.1 request. By default nginx only sends gzipped responses to HTTP/1.1 requests. (And HTTP/1.1 is over 15 years old, so anything like that that’s still sending HTTP/1.0 requests is hopelessly obsolete or broken.)

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.