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. Brotli allows a denser packing than gzip and deflate because of several algorithmic and format level improvements: the use of context models for literals and copy distances, describing copy distances through past distances, use of move-to-front queue in entropy code selection, joint-entropy coding of literal and copy lengths, the use of graph algorithms in block splitting, and a larger backward reference window are example improvements. The Brotli specification was generalized in September 2015 for HTTP stream compression (content-encoding type 'br'), and can now be used to encode any data sent by a web server to a web browser if both client and server support the format. This generalized iteration also improved the compression ratio by using a pre-defined dictionary of frequently used words and phrases.
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.:1 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.
Brotli was designed for use on a sequentially processed data stream (a bitstream),:2 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. The Brotli compressed data format was submitted to the Internet Engineering Task Force with a request for comment (RFC 7932) in July 2016. The Brotli data format is an integral part of the 2nd iteration of the Web Open Font Format.:3
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". Google's own implementation of the Brotli specification was released under the terms of the permissive free software MIT license in 2016. A formal validation of the Brotli specification was independently implemented by Mark Adler,cf. :126 one of the co-authors of the zlib/gzip compression format and library. Adler's implementation was released under the terms of the similarly permissive Apache license. Other implementations of the specification also exist, including one in the source-to-source haxe language.
Brotli was first released in 2013 for off-line compression of web fonts. The version of Brotli released in September 2015 by the Google software engineers contained enhancements in generic lossless data compression, with particular emphasis on use for HTTP compression. The encoder was partly rewritten, with the result that the compression ratio improved, both the encoder and the decoder have been sped up, the streaming API was improved, and more compression quality levels have been added. Additionally, the new release shows performance improvements across platforms, with decoding memory reduction.
Unlike most general purpose compression algorithms, 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. The decoding memory constraints can be circumvented by using Large Window Brotli, which is not compatible with RFC7932 ("regular" Brotli).
At its highest compression setting, Brotli can compress web content more densely than Zstandard, albeit at a slower speed.
Streams compressed with Brotli have the content encoding type "br".
- Mozilla Firefox introduced support for the 'br' content-encoding method in version 44 (released on 26 January 2016).
- Google Chrome has supported the 'br' content-encoding method since version 50 (released on 20 April 2016).
- Opera has supported the 'br' content-encoding method since version 38 (released 8 June 2016).
- Microsoft Edge has supported the 'br' content-encoding method since version 15 (released on 5 April 2017).
- Safari has supported the 'br' content-encoding method since version 11 (released on 5 October 2017).
Web server support
- For Apache HTTP Server, the 'br' content-encoding method has been supported by the mod_brotli module since version 2.4.26.
- Microsoft IIS has a IIS brotli community extension since March 2016 that adds support for the 'br' content-encoding method.
- nginx has a ngx_brotli module provided by Google since December 2016.
- Node.js features a built-in native en- and decoder since version 11.7.0, which can be used to support the 'br' content-encoding.
- LiteSpeed Web Server has included the 'br' content-encoding method for static files only since version 5.2 in July 2017.
- OpenLiteSpeed first introduced the 'br' content-encoding method for static files only in version 1.4.27 as part of the web server.
- Cloudflare CDN offers a brotli option to compress data between its edge node and the user.
- NaviServer added support in version 4.99.17b1
Support in other software
- cURL can be compiled with optional libbrotli-based support for the 'br' content-encoding method as of version 7.57, released on 29 November 2017.
- Alakuijala, Jyrki; Szabadka, Zoltan (2016), RFC 7932: Brotli Compressed Data Format, Internet Engineering Task Force Request for Comments, Fremont, CA: IETF Trust.
- Alakuijala, Jyrki; Kliuchnikov, Evgenii; Szabadka, Zoltan; Vandevenne, Lode (22 September 2015), "Comparison of Brotli, Deflate, Zopfli, LZMA, LZHAM and Bzip2 Compression Algorithms" (PDF), The Comprehensive R Archive Network, r-project.org.
- Szabadka, Zoltan (September 22, 2015), "Introducing Brotli: a new compression algorithm for the internet", Google Open Source Blog, Mountain View, CA: opensource.googleblog.com.
- Adler, Mark (Jan 26, 2015), "Brotli specification review and verification", Adler brotli, San Francisco: GitHub.
- Sheeter, Rod (February 18, 2015), "Smaller Fonts with WOFF 2.0 and unicode-range", Google Open Source Blog, Mountain View, CA: opensource.googleblog.com.
- Chirgwin, Richard (September 23, 2015), "Google's new squeeze: Brotli compression open-sourced", The Register, theregister.co.uk.
- Larkin, Henry (2007), "Word Indexing for Mobile Device Data Representations", Proceedings of the 7th IEEE International Conference on Computer and Information Technology, IEEE.
- Goodger, Ben; et al. (26 January 2016), "Firefox 44 release notes", Mozilla Firefox, Mozilla Foundation.
- Baheux, Kenji (15 January 2016), "Accept-encoding: br on HTTPS connection", Chrome Platform Status, chromestatus.com.
- Trace, Rob (December 20, 2016), "Introducing Brotli compression in Microsoft Edge", Microft Edge Developer, blogs.windows.com
- "Changes with Apache 2.4.26", Apache HTTPD repository, svn.apache.org.
- ""What will Cloudflare compress?"". support.cloudflare.com.
- Stenberg, Daniel; et al. "curl - Changes". curl.haxx.se. Retrieved 14 January 2018.
- - Finley, Klint (22 September 2015), "Hooli, I Mean Google, Gives Away Compression Code for Free", Wired Online, wired.com.