Gzip Page Assets With Nginx

This is something I feel like I should have known, but didn’t. By default, Nginx only applies gzip compression to text/html MIME-types. This means any additional assets like css, js, fonts etc. are not compressed.

The image below shows gzip section in the default nginx.conf file. As you can see, gzip is turned on but the gzip_types directive is commented out.

To enable gzip compression for MIME-types other than text/html this line should be uncommented and include a list of MIME-types that you want Nginx to compress (or override this setting per-application rather than in the global config). There are already a few types listed, but a more complete list can be found here to give you some additional possibilities.

If you are using TLS/SSL, be sure you understand the Breach exploit before enabling HTTP compression on your site/server to make sure gzip is safe for your application. http://www.breachattack.com/

Cheers!