KeyCDN Launches Brotli Support
At KeyCDN , we’re happy to announce that the next generation of file compression support is here! That’s right, as of today (February 16, 2017) the option to enable Brotli support has been rolled out to all KeyCDN customers at no extra cost.
For users who want to further compress their files in order to deliver content even faster, Brotli will enable you to do just that. You’ll notice that in the KeyCDN dashboard under the advanced settings section of your zone, there is now a new option called Cache Brotli.
This feature is disabled by default, however in this post, we’ll cover what you need to know about how KeyCDN supports the new Brotli feature and how you can start taking advantage of its benefits.
What Is Brotli?
Brotli is a new compression algorithm that was developed by Google in order to help further reduce the size of files. This means less bandwidth is used to transfer files that take advantage of Brotli compression and visitors accessing these files receive them faster. Many studies such as Google's Compression Algorithm Study have shown impressive compression results using Brotli. A 20-26% higher compression ratio has been seen when comparing Brotli to Zopfli (another modern compression algorithm).
Sam Saffron, co-founder of Discourse, also ran a few tests and gathered some impressive results of his own. The chart below shows a comparison in size savings using various compression algorithms against 8 different assets.
As we can see, when compared to the other compression algorithms (Gzip and Zopfli) brotli_11 always comes out ahead and brotli_5 is better in most cases as well. The numbers beside each compression algorithm (e.g. gzip_5 and brotli_5) refer to the level of compression. The higher the number, the greater the file size savings. However, the tradeoff to this is that the higher the compression level, the more resources are required to compress/decompress a file.
A few highlights and important facts about Brotli you as a user should be aware of include:
- Brotli offers a comparable compression ratio offered by the best compression methods and uses less CPU. Additionally, it is considerably better than Gzip.
- Both the server and browser must be Brotli compatible to take advantage of this compression method (more on browser and web server support below).
- Browsers will not accept Brotli encoding over HTTP connections, only HTTPS.
How Does KeyCDN’s Brotli Support Work?
At KeyCDN, we always have performance at top of mind. Therefore, we’ve introduced Brotli support in a way that ensures your files are delivered using the Brotli encoding without sacrificing time waiting for the Brotli compression to take place on the CDN level. This is the difference between on-the-fly Brotli compression and Brotli compression that’s introduced at the origin server level.
To use KeyCDN’s Brotli compression feature, your origin server must first support Brotli. This allows for your files to be compressed using the Brotli algorithm on your origin server which therefore allows the edge server to cache and deliver the Brotli compressed files. Using this method, you also have the flexibility to define whichever Brotli compression level you want (a good starting pointing is Brotli 4). To check if your origin server currently supports Brotli, use our Brotli test tool.
Once you’ve verified that your origin server supports Brotli and that you have the Brotli feature enabled in the advanced settings of your zone, you’ll be able to start delivering Brotli compressed assets to compatible browsers through KeyCDN. Take the following example which we’ve setup using the Brotli-enabled origin server of our KeyCDN tools page.
Requesting an asset from this page using the CDN URL will add the value:
br to the accept-encoding Request Header. Furthermore, you’ll also notice that the content-encoding Response Header will return the Brotli value:
Brotli Browser Support
Brotli browser support has certainly improved (and continues to improve) even in just a matter of months. At the beginning of 2016, the only major browser that supported Brotli was Firefox. Now, other browsers such as Chrome, Opera, and Edge have jumped on board to also support the delivery of Brotli compressed assets.
As mentioned above, if you have the KeyCDN Brotli feature enabled, however a visitor that isn’t using a supported web browser requests an asset, they will be delivered that asset either Gzipped or uncompressed depending on the compression settings defined.
Brotli Web Server Support
Similar to browser support, web servers continue to build upon supporting Brotli compression. Depending upon which web server you’re using, you will need to use a dedicated implementation method. The following resources should help steer you in the right direction based on your web server.
- Nginx has a Brotli extension offered by Google requiring you to compile Nginx by yourself in order to use it.
- Apache offers a dedicated Brotli extension.
- Microsoft IIS doesn’t offer any official Brotli support, however there is a community module that adds support.
- Node.js is similar to Microsoft in that there is no official support for Brotli however there exists a community module.
KeyCDN is proud to be amongst one of the first CDN providers to offer Brotli support. Fun fact about Brotli: it is named after the Swiss bakery product - Brötli, which is commonly referred to as “small bread”. Only fitting that KeyCDN is a Swiss company ;).
We know that speed is extremely important to our customer so providing the ability to compress web files even smaller will help further improve web performance.
We would love to hear your feedback! If you have any questions regarding this new feature feel free to comment below.