
Business Intelligence as a Service
Try PlusClouds Eaglet service and find high quality B2B hot leads and opportunites with AI support.
Brotli is a lossless and open-source compression algorithm developed by Google. Initially designed to reduce the size of web fonts, Brotli has now become a general-purpose data compression format. Brotli, which offers the same speed of decompression while producing smaller files, serves as an alternative to gzip and Deflate.
Brotli was actually developed initially for compressing WOFF2 web fonts. It is a continuation of Zopfli, another compression algorithm developed by Google, which is compatible with gzip, zlib, and Deflate. Although Zopfli and Brotli consume more CPU resources, they offer much higher compression ratios compared to gzip, zlib, and Deflate. Over time, Brotli transitioned to its own file format with a .br extension, giving up backward compatibility. What distinguishes Brotli from others is that it can only be used with secure connections. This is made possible by intercepting and scanning proxies that halt unencrypted HTTP traffic. Some proxies encountering a Brotli file have been observed to attempt to convert the Content-Encoding header from br to gzip to pass the file. By restricting Brotli to HTTP, Google has eliminated this interference, facilitating faster adoption of Brotli.
Compared to Deflate, Brotli offers an impressively high compression ratio but consumes significantly more CPU. According to a study conducted by Google in 2015, Brotli's maximum compression level is 29% higher than Deflate's maximum compression level. However, at this level, Brotli's compression and decompression speeds are 97% and 17% lower than those of Deflate, respectively (0.5 and 289.5 MB/s compared to 15.5 and 347.3 MB/s).
Due to significantly lower compression speeds, companies prefer to pre-compress files when using Brotli. In 2017, Dropbox managed to reduce the size of static content on Dropbox.com by an average of 20-25% by transitioning to Brotli. Since the content is static, Dropbox can serve the pre-compressed data directly to users.
Most of the most commonly used web servers support Brotli either directly or through modules. A large number of CDNs (Content Delivery Networks) also support Brotli.
Like gzip, zlib, and Deflate, Brotli also offers different levels of compression. Higher levels generally provide higher compression ratios at lower speeds. They can be ranked from level 1, which is the slowest, to level 11, which is the fastest. Level 5, which offers a good balance in terms of both speed and file size, is particularly recommended for those pursuing dynamic compression.
Apache supports Brotli with the mod_brotli module included in version 2.4.26. To enable Brotli, you can enter the following in your virtual hosting configuration:
Compress common text-based MIME types
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript
Skip content that's already compressed
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-brotli
Sets the compression level (defaults to 5)
BrotliCompressionQuality 6
mod_brotli decompresses data with each request. To serve pre-compressed data, copy Brotli files to a folder accessible by Apache. Then, enter a rewrite condition in your virtual hosting configuration to work with these files instead of gzip counterparts.
Serve brotli compressed CSS files if they exist and the client accepts brotli.
RewriteCond "%{HTTP:Accept-encoding}" "br"
RewriteCond "%{REQUEST_FILENAME}\.br" "-s"
RewriteRule "^(.*)\.css" "$1\.css\.br" \.js" "$1\.js\.br" $">
Serve correct encoding type.
Header append Content-Encoding br
Force proxies to cache brotli &
non-brotli css/js files separately.
Header append Vary Accept-Encoding
Nginx supports Brotli with the ngx_brotli module. The module actually consists of two separate modules: one for on-the-fly compression and the other for pre-compression. To use Brotli, it is necessary to compile Nginx with the provided module.
brotli on; # Enables on-the-fly compression.
brotli_static on; # Enables serving pre-compressed files.
brotli_types *; # Enables compression for all MIME types. text/html responses are always compressed.
brotli_comp_level 6; # Sets the compression level (defaults to 6).
It is possible to use Brotli in IIS with the open-source “Brotli Compression Scheme Plugin” module. The installation script automatically performs the installation and configuration of Brotli for all IIS sites. You can configure the compression parameters by opening the applicationHost.config file and navigating to the
...
...
As of the date this article was written, the only compressible options are static and dynamic compression levels.
Many CDNs, such as Key CDN and Akami, explicitly support Brotli. However, other CDNs may not decompress Brotli-encrypted files and may even attempt to revert to gzip. When LinkedIn tested Brotli across their entire site in 2017, it was noted that all five of their CDNs reverted the Vary Accept-Encoding Header ’ to gzip even when Brotli files were served. Additionally, since LinkedIn's content servers processed responses with Content-Encoding: br, CDNs became confused and failed to cache the data.
To resolve this issue, LinkedIn moved Brotli files to a different URL and removed the Content-Encoding: br header. After a file is cached by the CDN, the header is re-added to each response to the client. While this does not completely solve the issue, an improvement of around 2-6.5% in performance has been observed, with particularly positive effects for mobile users.
Brotli is supported by most modern browsers with exceptions for Internet Explorer 11 and Opera Mini. Google Chrome 50, Firefox 44, Edge 15, Opera 38, and Safari started supporting it in version 11. Worldwide, 84.25% of browsers, and 83.42% in the United States, support Brotli.
However, browsers that do not support Brotli will not request Brotli in their Accept-Encoding headers and will resort to alternative compression algorithms.
Brotli brings a next-generation understanding of data compression and storage. With the potential to reduce website sizes by 20%, Brotli offers a faster and smaller web experience. You can find more information about Brotli on the official GitHub page.
If you are a journalist, who has desire to dig deep in topics related to businesses and sectors, we want to work with you!
With the AutoQuill tool that PlusClouds has started to offer to its affiliate partners, content creators will be able to sell with a single click. Let us show you how you can get your share of this revolution.