Brotli and gzip are amazing


Home | Blogs

Brotli and Gzip are compression methods that also work for the web. They make searching the web much faster. The best part about Brotli and Gzip is that the client sends what they are able to use, so there is no risk of browsers not being able to use your site.

According to caniuse.com, gzip is supported by pretty much all browsers as it is part of the MDN Docs. Gzip also came out in 1992, so it has been a web standard for a long time.

Brotli is newer and came out in 2016, and most browser versions that are newer than 2016 have Brotli support. But because browsers send the compression they accept, webservers won't send it to clients that don't support it.

Brotli reduces the size of my home HTML page by 41% and the CSS file by 31.8%. On my git server, my home page is 38% the size, my CSS is 12% the size, and my favicon is even smaller at 19.5% the size. My profile picture (that is, a png) is even compressed to 89% of its original size.

My home html page is 52% smaller with gzip, and the CSS is 38.6% smaller. With my git server, my home page is compressed about 46%, my CSS is compressed about 18.4%, and my favicon is compressed about 25%.

Brotli is clearly the winner, but even gzip does really well. Brotli looks to make a 6% compression improvement, and I have seen that these values do scale up, and even for the better. I saw a Blazor website have a compression ratio of 85% over the whole site just with Brotli. These compression amounts can be very noticeable for users, as a big site can take 1/5 to 1/3 the amount of time to load a page. If you have a site and don't have Brotli or Gzip enabled, please enable them.

To add Brotli to Nginx, you can follow this guide that I used How to Install Brotli Module for Nginx on Ubuntu 20.04, after you have followed the guide and nginx has updated again, I have made unginx.sh, a script to automatically add brotli support to your updated nginx. Run it as root.