WordPress is a great CMS for a variety of reasons. It’s easy to use, has a great community, is configurable, and much more. However, one thing that WordPress users seem to struggle with quite often is the performance of their WordPress site. This post will take a look at Brotli Compression, and its effects on the performance of WordPress.
Disclaimer: I work for KeyCDN and have referenced a couple of their articles and tools here.
There are many “Speed up WordPress posts” available online that provide great insight into how to improve the loading times of your site using a variety of methods, including optimizing via plugins. However, since Google’s release of their newest compression algorithm – Brotli, there hasn’t been much data collected to determine what sort of performance improvements one might experience from enabling it on a WordPress site.
In this article, we’re going to be measuring the effects of Brotli compression by testing WordPress performance under three different scenarios:
- WordPress with Gzip enabled
- WordPress with Brotli enabled
- WordPress with Brotli enabled + a Brotli-supported Content Delivery Network
What Is Brotli Compression?
Named after a Swiss bakery product, Brotli is a relatively new compression algorithm released by Google back in 2015. According to Google, Brotli compression uses a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling.
Google has performed various tests using the Brotli compression algorithm and has benchmarked the results against other modern compression algorithms. Based on this study, Google found that Brotli outperformed Zopfli (another modern compression algorithm) on average by 20-26% in terms of the compression ratio. When it comes to performance, having your files compressed to be smaller in size is always welcome.
Install and Configure Brotli on Your Server
One of the minor downsides of Brotli is that it is not yet officially distributed on any popular web servers. This means that if you want Brotli enabled on your server today, you’ll need to do a bit of your own configuration work. For the following Brotli performance tests, everything was carried out on Ubuntu 16.04.2 LTS running Nginx (Need to learn about using Nginx? Check out the SitePoint Premium course Faster Websites with Nginx). Below, we’ll step through the process of how you can get Brotli up and running using the same OS and web server.
Ubuntu 16.04 is the first Ubuntu distribution that allows you to install Brotli using
apt-get. To do this simply run:
$ apt-get update && apt install brotli
$ git clone --recursive https://github.com/google/ngx_brotli ngx_brotli $ wget http://nginx.org/download/nginx-1.13.0.tar.gz $ tar zxvf nginx-1.13.0.tar.gz $ cd nginx-1.13.0 $ ./configure --add-module=../ngx_brotli $ make && make install
Brotli should now be properly installed on your server. Next, you’ll need to configure your
nginx.conf file to specify your desired configuration directives. The following directives were used for the purposes of these performance tests; however, you can modify them as you see fit.
A full list of directives can be found on Nginx module Github page.
nginx.conf file was modified, the last step is to reload Nginx. To do this, run the following command:
systemctl reload nginx
Continue reading %Measuring the Effects of Brotli Compression on WordPress%