Pagespeed - Enable compression with NGinx

This post is the first in a series to come showing how to optimize a Pelican powered page with NGinx.

There are popular tools to check you page speed like:

and many more...

Note: The 2nd post tackling browser caching is also available now.

As described in Compression and decompression NGinx "performs compression before sending responses to clients" (if configured correctly).

Adding the following snippet to our nginx.conf did the trick.

server {
  ...
  gzip on;
  gzip_types      text/plain text/css application/javascript application/x-javascript text/javascript;
  ...
}

It resulted in the following "Optimizations Found":

You have compression enabled.

The next post will most probably be about: "Leverage browser caching". Stay tuned...

Note: In the first attempt we also had the problem NGINX gzip not compressing JavaScript files - and added application/javascript text/javascript to the list of gzip_types.

Show Comments