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
- What is Brotli Compression
- Brotli vs Gzip
- Does InMotion Use Brotli?
- Upcoming Articles
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 Page||Gzip Compression Rates||Brotli Compression Rates|
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:
Thoughts on “Brotli Compression Algorithm”
I have the shared hosting “power” plan and can set the brotli levels in the Cache manager in CPanel. I have a static HTML site. If I set the brotli level to “11” will the CPU have to compress each page in advance or does it have to do it “on-the-fly.” In other words, will there be a CPU performance penalty?
Hello Hubert – Thanks for the question! It’s a great question! Yes, the site is dynamically compressed per site request. The Brotli algorithm was developed with performance in mind, so CPU performance is generally not affected. If you’re taking the parameters of the compression higher, then it is possible that you will see an increase in CPU performance. However, as you have a static site, it may still be minimal. The best way to check on this is to look at the logs to see how performance is affected by your settings. Unfortunately, with a shared hosting plan you will not have access to see the overall server CPU use level. I would recommend submitting a ticket to the live technical support team. Explain what you’ve done and ask if there is a significant CPU use penalty that may affect your site’s performance. They can access the server and give you a clear answer.