Recommended gzip compression config

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by sirkitree on April 3, 2012 at 11:29pm

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

Posted by akuznecov on April 4, 2012 at 12:49am

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

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

Posted by sirkitree on April 4, 2012 at 1:29pm

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

Posted by omega8cc on April 4, 2012 at 1:46pm

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

Hrm

Posted by sirkitree on April 4, 2012 at 3:27pm

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

Posted by perusio on April 4, 2012 at 4:08pm

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

Notta :(

Posted by sirkitree on April 4, 2012 at 4:29pm
HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: 2012年4月04日 16:27:05 GMT
Content-Type: application/x-javascript
Content-Length: 15624
Last-Modified: 2012年2月28日 15:30:24 GMT
Connection: keep-alive
Accept-Ranges: bytes
HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: 2012年4月04日 16:28:24 GMT
Content-Type: text/css
Content-Length: 8852
Last-Modified: 2012年2月28日 15:30:24 GMT
Connection: keep-alive
Accept-Ranges: bytes

curl -I -H 'Accept-Encoding:

Posted by brianmercer on April 4, 2012 at 4:44pm
curl -I -H 'Accept-Encoding: gzip,deflate' http://www.mysite.com

Looks like text/html is

Posted by sirkitree on April 4, 2012 at 5:01pm

Looks like text/html is success from that:

HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: 2012年4月04日 17:00:30 GMT
Content-Type: text/html
Last-Modified: 2012年2月28日 15:37:02 GMT
Connection: keep-alive
Content-Encoding: gzip

css & js with that

Posted by sirkitree on April 4, 2012 at 5:05pm

CSS

HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: 2012年4月04日 17:02:03 GMT
Content-Type: text/css
Last-Modified: 2012年2月28日 15:30:24 GMT
Connection: keep-alive
Content-Encoding: gzip

JS

HTTP/1.1 200 OK
Server: nginx/1.0.14
Date: 2012年4月04日 17:02:32 GMT
Content-Type: application/x-javascript
Last-Modified: 2012年2月28日 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

Posted by sirkitree on April 4, 2012 at 5:28pm

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:

AltStyle によって変換されたページ (->オリジナル) /