Brotli Compression

Brotli is a data format specification for data streams compressed with a specific combination of the general-purpose LZ77 lossless compression algorithm, Huffman coding and 2nd order context modelling. Brotli was initially developed to decrease the size of transmissions of WOFF2 web fonts, and in that context was a continuation of the development of zopfli, which is a zlib-compatible implementation of the standard gzip and deflate specifications.

Brolti History

The Brotli specification was developed in 2013-2016 by Google employees Jyrki Alakuijala and Zoltan Szabadka, and was accompanied by a reference implementation developed by the two authors of the specification together with Evgenii Kliuchnikov and Lode Vandevenne, who had previously developed Google's zopfli reimplementation of deflate/gzip compression formats in 2013. Unlike zopfli, which was a reimplementation of an existing data format specification, Brotli was a new data format, and allowed the authors to improve compression ratios even further.

How Brolti Works

Brotli was designed for use on a sequentially processed data stream (a bitstream), rather than on discrete random-access files. This makes Brotli particularly suitable for compressing data as it is sent over a network connection. Under ideal circumstances, this reduces the volume of data being transmitted. The transmission of a compressed stream may then also complete sooner than would be the case for an uncompressed stream, or a stream compressed with a less efficient stream compressor such as gzip or deflate. While gzip and deflate are comparatively light-weight compressors (i.e. less processor- and memory-intensive than Brotli), and are already widely supported by many web servers, Brotli has not yet been implemented as widely.

While Google's zopfli implementation of the deflate compression algorithm is named after a Swiss German word for a braided sweet bread and literally means "little plait", brotli is a Swiss German word for a bread roll and literally means "small bread"

Streams compressed with Brotli have the content encoding type "br".

Brotli Dictionary

Brotli uses a pre-defined 120 kilobyte dictionary, in addition to the dynamically populated ("sliding window") dictionary. The pre-defined dictionary contains over 13000 common words, phrases and other substrings derived from a large corpus of text and HTML documents. Using a pre-defined dictionary has been shown to increase compression where a file mostly contains commonly used words.

Brotli's decoding memory use is limited to 16 MB. This enables decoding on mobile phones with limited resources, but makes Brotli underperform on compression benchmarks having larger files.

Brotli compression supported by all web browser with "br" content enconding. 'br' content-encoding method has been supported by all web web servers. cURL can be compiled with optional libbrotli-based support for the 'br' content-encoding method.