The Difference Between Brotli And Gzip Compression Algorithms To Speed Up Your Site
Publisher: Psychz Networks, April 04,2022
Introduction
Imagine that you are hungry, and you open your web browser and type in your favorite food name to check for the nearest restaurants that serve it, and you click on one of the links that appear in the result. Now, count the number of seconds it takes to load. Is it one second? Three? Five? Monitor how your patience wavers as the seconds go up – are you tempted to click away? The answer is Yes!
According to Google analytics, 40% of people abandon a website that takes more than 5 seconds to load, and a 1-second delay in page response can result in a 7% reduction in conversions. Slow load speed on a web page can lead to a lack of sales conversions and a general loss of traffic for an online business. Today, the customers would prefer to search for a new page than spend time waiting for a page to load. Also, Google uses website page load time to determine your site's search engine ranking. The further down the page, the fewer people will see and click on your site. If your site is slow to load, you stand to lose your existing consumers and new users as well.
Why are compressions necessary?
The performance and speed of a website play a tremendous role. If your website isn't fast enough, the user will not wait for it to finish loading. A fast website increases conversion rates and leads you to perform well on search engines. Website compression essentially smoothens this process to reduce the duration of file transfers and rendering.
Using HTTP compression makes a website load faster and guarantees a better user experience. Running no compression on HTTP makes for a worse user experience, may affect the growth rate of the related web service, and affects search rankings. The effective reduction can reduce page weight and improve web performance and therefore is an integral part of search engine optimization. By compressing your site, you essentially make it smaller and quicker to retrieve. This results in significant performance improvements, as well as happier visitors. Compressing your files will allow browsers to download them much quicker. When the browser requests the page resources from your server, the server will tell the browser that the resources are compressed. The browser will then download the resources and then decompress them.
In most cases, it is either a lossless compression or lossy compression. The former saves all repetitive data, and the latter deletes all redundant data. Compression is recommended for most text-based assets, such as HTML, CSS, JavaScript, JSON, or SVG. Currently, practically all text compression is done by two HTTP content encodings: Gzip and Brotli, and Browsers widely support both. Both Brotli and Gzip are based on a lossless compression algorithm.
Now, let us discuss these two compression techniques (Brotli & Gzip) in detail.
About Brotli
Brotli is a compression algorithm developed by Google that 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, and 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.
- JavaScript bundles compressed with Brotli are 14 percent smaller than Javascript bundles compressed with Gzip.
- HTML files compressed by Broti are 21 percent smaller than their Gzip equivalents.
- CSS files compressed by Brotli are 17 percent smaller than those compressed by Gzip.
Since most websites rely on all three of these assets, that's a considerable difference in asset sizes compared to Gzip. These savings, in turn, will make a noticeable improvement in your website's performance.
Browsers that support Brotli send 'br' along with 'gzip' in the accept-encoding request header. If Brotli is enabled on your web server, you will get a response in Brotli compressed format.
Content-encoding: br
About Gzip
Gzip is the oldest and most common of the two. The first actual version, version 1.0, was released in early 1993. Gzip was designed as an all-purpose compression library based on a lossless compression algorithm. The theories behind Gzip were based on the earlier compression algorithm, DEFLATE. Gzip is highly popular and is very good at making files small and that makes it used today both in different operating systems and as a primary compression algorithm for web servers.
GZIP is based on the DEFLATE algorithm, and while people usually refer to it as a single compression tool, there are different "levels" of GZIP compression. In total, GZIP has nine quality levels that balance compression level vs. speed:
.
.
Level 9 – maximum file size savings but comparatively slow compression speed.
All major browsers support GZIP, and most web hosts also support GZIP out of the box.
Brotli vs. Gzip
Both algorithms do an excellent job at what they were designed to do. Gzip continues to be used on the web because it is still better than nothing. However, as Brotli grows in popularity, more and more web servers prefer Brotli over Gzip. Let us now discuss which compression technique is better than the other using several parameters as yardsticks.
Browser Support
One of the significant drawbacks of Brotli is that it is relatively newer and hence has a limited number of browser support. On the other hand, Gzip has been in the industry since the early 90s and is nearly accepted by all the browsers available in the market.
Compression Size
Brotli offers a better compression ratio than GZIP. That is, it compresses your website "more" than GZIP. Brotli is better at compressing static data because of its superior compression ratio. However, GZIP is better at compressing dynamic data because of its often superior compression speed.
Webserver Settings
Brotli integration requires server-side configuration changes and requires enabling it. This is not the case with Gzip, as it comes as a standard in all major web servers. Both Nginx and Apache web servers come with their Brotli extensions. Having said that, webservers with Brotli support need to keep the Gzip compression too, and this helps the webserver handle requests from non-Brotli supported websites.
Psychz CDN
Currently, Brotli is the best compression algorithm available for websites. If you see you are not offering Brotli, move to a web hosting partner that has it enabled. Although Brotli may sometimes run slower on its highest compression settings, you can quickly achieve an ideal balance between compression speed and file size by adjusting the settings. If you can manually install Brotli on your server, Brotli is undoubtedly still a good option. It's just not as popular and therefore not as easy to use. Every millisecond counts, so any action you take to speed up your application improves your chances of retaining users.
Psychz CDN widely uses Gzip and Brotli services as inbuilt functionality to increase the speed and performance of your website while also lowering the latency. Our CDN service engages Brotli or Gzip technologies for data compression and decompression to enhance the performance of your content delivery. Using our dashboard, you can engage any of the two services per your technical requirement.
Please look at how easy it is to manage Brotli or Gzip features without even having any technical expertise. Please click on the links below to learn more about working the Brotli and Gzip feature on Psychz CDN.
Manage Brotli on Psychz CDN
https://www.psychz.net/client/kb/en/brotli.html
Manage Gzip on Psychz CDN
https://www.psychz.net/client/kb/en/gzip.html
To know more about Psychz's CDN service, please visit https://www.psychz.net/cdn.html. You can also write to our sales team for more technical information at sales@psychz.net or call 1-800-933-1517.