Brotli Compression Algorithm

Date: 08/30/2019       2 Minutes to Read

In this article: 

This article explains what the Brotli Compression Algorithm is and how it can benefit your website. We also compare it to Gzip and list all the InMotion Hosting servers it is available on.

Website Compression

All of the content of your website must be transferred to the visitor’s browser before it can be displayed. If the files are compressed before being sent it can make the transfer smaller but uses your server’s resources. For example, the more you compress data the faster it can be transferred, but it can slow your server down if it is constantly processing the compression. This requires a delicate balance of compression using server resources; and transfer speed with bandwidth usage. Many of you are familiar with gzip, which handled most server compression until recently. While gzip does a good job of compressing data, there is always room for improvement. This leads us to the Brotli Compression Algorithm.

What is Brotli Compression?

In 2015 Google introduced a new open-source compression algorithm called Brotli. This new algorithm promises better compression while using fewer resources. Compressing the responses being sent from NGINX to your browser is a great way to optimize your website. This can specifically help reduce your time to first byte. While it is not compatible with all browsers at this time, it does already work with the major ones such as Chrome, FireFox, and Edge. Brotli is also supported by popular content delivery networks (CDN) like Cloudflare and Sucuri.

How Does your Browser handle the Data?

If you visit a website, your browser sends a list to the server of the encoding options it will accept. This is included in the Accepts-Encoding header. The server then:

  • Takes the list of encoding options
  • Determine which ones it has available
  • Compress the data using Brotli or gzip
  • Sends it back to the browser with the Content-Encoding so the browser knows how to decode the data.

Brotli vs Gzip

We performed some tests on a WordPress site so we could compare the compression rates. First, we visited specific pages or files on our WordPress site with gzip enabled. Then, we reviewed the compression rates via the cPanel access log. Next, we deployed Brotli on the same server and tested the same pages and files. Finally, we reviewed and compared the results, here is a table:

WordPress PageGzip Compression RatesBrotli Compression Rates
/[gz=2.71][br=3.00]
/wp-includes/css/dist/block-library/style.min.css?ver=5.2.2[gz=5.32][br=6.06]
/wp-includes/css/dist/block-library/theme.min.css?ver=5.2.2[gz=2.52][br=2.85]
/wp-includes/js/wp-emoji-release.min.js?ver=5.2.2[gz=2.75][br=7.06]
/wp-content/themes/twentynineteen/style.css?ver=1.4[gz=6.21][br=2.04]
/wp-includes/js/wp-embed.min.js?ver=5.2.2 [gz=1.83][br=3.03]
/wp-content/themes/twentynineteen/print.css?ver=1.4[gz=3.06][br=3.40]

Here you can see that we got better compression rates with Brotli deployed than with gzip. I do not have any detailed information, but my System Administrator confirmed there was no noticeable difference in CPU usage. This confirms Google’s promise of better compression rates.

Does InMotion Use Brotli?

Now that you know what Brotli is, you may be wondering… does InMotion Hosting utilize the Brotli Compression Algorithm on their servers? Since we now offer a variety of hosting plans, It depends on which one you sign up for. The following plans include Brotli compression already:

Since you can get root access to some servers, you can install Brotli yourself on the following:

Upcoming articles

Check back often, since we will be releasing the following articles on Brotli Compression soon.

  • How to Install Brotli Compression on CentOs
  • How to Configure Brotli Compression

Leave a Reply