Compression and beyond

Brotli, GZIP? What is all about anyway?

Brotli and gzip are both compression algorithms used to reduce the size of your website files (usuali HTML, CSS and JavaScript). Typically, compressed files are sent from your webserver to the client’s web browser where it is then decompressed and parsed. Web developers don't need to implement compression mechanisms, both servers and browsers have built in compression alghoritms. All this is happening under the hood, as long as the server is configured adequately. Compression happens on the fly and without knowing anything about it.

Should I use compression?

Compression important in order to increase the performance of a Web site. For some type of files size reduction is expected to reach up to 70%. This lowers the needed bandwidth capacity. This reduction can result in significant cost savings. Overall, HTTP compression algorithms built curently into web servers and web clients improve transfer speed and bandwidth utilization.

Brotli, GZIP or something else?

All modern browsers and servers support compression algorithms. Normaly browsers and servers negotiate the compression algorithm to use. Today, only two alghoritms are relevant: gzip and Brotli. The most common one is GZIP, but Brotli (BR) is the new challenger and most probably the winner. Brotli is more efficient than gzip. Using Brotli compression you should expect HTML files to be about 20% smaller than using gzip.

Brotli and GZIP should be enabled

You can configure your webserver to support multiple encodings (like gzip and Brotli) at the same time. To select the algorithm to use, browsers and servers use content negotiation as fallows: The browser sends an Accept-Encoding header with the list of algorithms it supports in a order of precedence. The server picks one alghoritm, uses it to compress the response and uses the Content-Encoding header to tell the browser the chosen algorithm

HTTP compression. Check the headers

You can configure your webserver to support multiple encodings (like gzip and Brotli) at the same time. To select the algorithm to use, browsers and servers use content negotiation as fallows: The regular modern browser sends the header 'Accept-Encoding: br,gzip,deflate'. The server responds with Content-Encoding: header. If br, gzip or deflate found in Content-Encoding then compression is working.

How to enable Brotli

Check this tutorial on how to enable Brothli compression un Apache server here.

Check this tutorial on how to enable Brothli compression on NGINX server here.

Check this tutorial on how to enable Brothli compression on IIS server here.

Check out mywebserver speed and stress test tool

The tool is designed to test and benchmark your HTTP server. It is intended to give you an impression of how your server performs, how many requests per second your server is capable of serving.