Recommended gzip compression config

Events happening in the community are now at Drupal community events on www.drupal.org.
sirkitree's picture

It used to be that gzip compression setting were found within the nginx.conf file, such as:

    gzip  on;
    gzip_comp_level 1;
    gzip_proxied any;
    gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

However, looking over the latest within the nginx-for-drupal repo it's simply turned on by default.

Is this because it should be up to individual site configs (sites-available) to implement the other settings?

If so, what setting do you recommend, and why?

Comments

However, looking over the

akuznecov's picture

However, looking over the latest within the nginx-for-drupal repo it's simply turned on by default.

By default (with gzip on) you will have gzip_comp_level => 5 and gzip_types => text/html only

omega8cc's picture

See: https://github.com/omega8cc/provision/blob/master/http/Provision/Config/...

The reason why we didn't move also that one line to the server template in Aegir is to stay backward compatible without the need to edit default nginx config created with apt-get install nginx, to avoid duplicate directives and breaking the config.

BTW: text/html shouldn't be listed there, as it is included by default and adding it there may cause duplicate directive warning.

Thanks for the comments and

sirkitree's picture

Thanks for the comments and the reasoning!

So let's say I already have the gzip on, and things like css and js are not being compressed. Is it just a matter of adding the

gzip_types text/css application/x-javascript text/javascript;

to my config?

Yes, exactly

omega8cc's picture

By default only text/html is compressed: http://wiki.nginx.org/HttpGzipModule#gzip_types

Hrm

sirkitree's picture

Adding these in doesn't seem to help, even after removing the nginx cache entry, restarting nginx and php5-fpm - any hints on what else I should look at here? Relevant pieces?

No header

perusio's picture

Content Encoding: gzip when you do a curl -I myfile.css or myotherfile.js?

Notta :(

sirkitree's picture

HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: Wed, 04 Apr 2012 16:27:05 GMT
Content-Type: application/x-javascript
Content-Length: 15624
Last-Modified: Tue, 28 Feb 2012 15:30:24 GMT
Connection: keep-alive
Accept-Ranges: bytes

HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: Wed, 04 Apr 2012 16:28:24 GMT
Content-Type: text/css
Content-Length: 8852
Last-Modified: Tue, 28 Feb 2012 15:30:24 GMT
Connection: keep-alive
Accept-Ranges: bytes

curl -I -H 'Accept-Encoding:

brianmercer's picture

curl -I -H 'Accept-Encoding: gzip,deflate' http://www.mysite.com

Looks like text/html is

sirkitree's picture

Looks like text/html is success from that:

HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: Wed, 04 Apr 2012 17:00:30 GMT
Content-Type: text/html
Last-Modified: Tue, 28 Feb 2012 15:37:02 GMT
Connection: keep-alive
Content-Encoding: gzip

css & js with that

sirkitree's picture

CSS

HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: Wed, 04 Apr 2012 17:02:03 GMT
Content-Type: text/css
Last-Modified: Tue, 28 Feb 2012 15:30:24 GMT
Connection: keep-alive
Content-Encoding: gzip

JS

HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: Wed, 04 Apr 2012 17:02:32 GMT
Content-Type: application/x-javascript
Last-Modified: Tue, 28 Feb 2012 15:30:24 GMT
Connection: keep-alive
Content-Encoding: gzip

When I run it through Google's Page Speed app it says they're not compressed though. Perhaps that tool is stale. (/me looks for another tool)

yeah

sirkitree's picture

looks like google had my results cached as other sites on the same server are now working.

Thanks for all the fish! :)

Nginx

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: