Brotli Compression vs Gzip – The secret behind fastest websites
Brotli compression vs Gzip – Which compression algorithm should I choose?
That was a recent customer request that we received in our help-desk for Server Management Services.
Website users simply abandon slow-loading pages and go elsewhere. Compressing website assets is one of the sure-shot ways for faster page loading.
In this write-up, we’ll do an analysis of Brotli compression vs Gzip and their impact on website speed.
Need to know more on Brotli Compression vs Gzip?
A data compression technique removes and replaces repetitive data elements to reduce the data size. That makes the website elements load faster. Each compression method differs slightly.
In most cases, it is either a lossless compression or lossy compression. The former saves all repetitive data and the latter deletes all repetitive data.
Both Brotli and Gzip are based on a lossless compression algorithm.
Today, we are going to have a discussion on Brotli Compression vs Gzip.
What makes Brotli different from Gzip?
Let’s now check on the major differences between Brotli and Gzip compression algorithms.
Brotli – A compression algorithm developed by Google. This gives a better compression ratio by using a dictionary of common keywords and phrases on both client and server-side. This is optimized mainly for small text documents.
Therefore, it suits more for serving static content such as HTML pages and fonts. Also, this has 11 preset quality settings and is labeled from 1 to 11.
Gzip is the most used compression algorithm on internet. Unlike Brotli, Gzip is most often used to compress web pages, Tar archives, and text files.
It allows reducing the size of a file by keeping the original file mode, timestamp, and ownership.
Gzip has 9 preset quality settings and is labeled from 1 to 9. Popular applications like WordPress support Gzip out of the box. And, users can easily compress their websites with few clicks.
However, we can’t choose one over the other as these two have their own pros and cons. And, this depends a lot on the type of pages that you have on the website. Additionally, it matters much on the type of content that you deliver to your users.
What are the pros and cons of Brotli and Gzip?
It’s time now to discuss some pros and cons.
1. Compression size
But, it is found less suitable for compression of data streams as the compression performance is slightly slower when comparing with Gzip.
2. Browser support
Unfortunately, one of the main disadvantages of Brotli comes with browser support. It is not supported by all browsers. The major browsers that support Brotli include Google Chrome 49+, Mozilla Firefox 44+, Opera 36+, etc.
On the other hand, Gzip has been in the industry since the 1990s. It is best suited for all browsers and it shortens the transfer rate duration. But it can compress only regular files.
3. Webserver settings
To make Brotli work, it requires configuration changes at the server-side. Unlike gzip that comes as a standard in all major web servers, we need to enable Brotli at the server.
Fortunately, Google offers a Brotli extension for NginX webserver. Likewise, Apache also has its own Brotli extension. However, the Brotli extension requires tweaking the parameters to get the best performance. For Windows server users, Brotli may not be the best choice as IIS webserver does not officially support it.
Having said that, webservers with Brotli support need to keep the gzip compression too. This helps the webserver to handle requests from non-Brotli supported websites too.
Choosing the compression method
Here, in the Helpdesk request, our customer asked to suggest to him the best among Brotli and Gzip. He was having a website predominantly handing non-text data. He was using Apache webserver.
As the customer wanted to compress non-text data, our Support Engineers suggested him to use Gzip. This is because Brotli proves to be not the best option for compressing non-text data. Again, the tweaking of Gzip compression was pretty easy with the .htaccess files on his website.
[Having trouble in choosing among Brotli compression vs Gzip? – Our Experts are available 24/7.]
In this write-up, we did a study of Brotli Compression vs Gzip. We also saw how our Dedicated Engineers help customers to choose the best among Brotli vs Gzip for their website.