brotli

{{Short description|Open-source compression algorithm}}

{{About|the compression algorithm|Brötli, the Swiss-German bread roll it is named after|Bread roll#Europe}}

{{Infobox software

| name = Brotli

| title = Brotli

| logo = Brotli-logo.svg

| logo size = 64px

| author = Jyrki Alakuijala, Zoltán Szabadka

| developer = Jyrki Alakuijala, Eugene Kliuchnikov, Robert Obryk, Zoltán Szabadka, Lode Vandevenne

| released = {{Start date and age|2013|10|15|df=y}}

| discontinued =

| latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}}

| latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}|df=yes}}

| latest preview version =

| programming language = C

| operating system = Cross-platform

| platform = Portable

| size =

| genre = Data compression

| license = MIT License

| website = {{URL|https://brotli.org/}}

}}

Brotli is a lossless data compression algorithm developed by Jyrki Alakuijala and Zoltán Szabadka. It uses a combination of the general-purpose LZ77 lossless compression algorithm, Huffman coding and 2nd-order context modelling.

Brotli is primarily used by web servers and content delivery networks to compress HTTP content, making internet websites load faster. A successor to gzip, it is supported by all major web browsers and has become increasingly popular, as it provides better compression than gzip.{{Citation needed|date=March 2024}}

History

Google employees Jyrki Alakuijala and Zoltán Szabadka initially developed Brotli in 2013 to decrease the size of transmissions of WOFF web font.{{citation |last=Sheeter |first=Rod |chapter=Smaller Fonts with WOFF 2.0 and unicode-range |date=February 18, 2015 |title=Google Open Source Blog |location=Mountain View, CA |publisher=opensource.googleblog.com |chapter-url=https://developers.googleblog.com/2015/02/smaller-fonts-with-woff-20-and-unicode.html}}. Alakuijala and Szabadka completed the Brotli specification during 2013{{ndash}}2016. The specification was accompanied with a reference implementation developed by two additional authors, Evgenii Kliuchnikov and Lode Vandevenne, who had previously developed Google's zopfli implementation of deflate and gzip compatible compression in 2013.{{citation |first1=Jyrki |last1=Alakuijala |first2=Evgenii |last2=Kliuchnikov |first3=Zoltan |last3=Szabadka |first4=Lode |last4=Vandevenne |chapter=Comparison of Brotli, Deflate, Zopfli, LZMA, LZHAM and Bzip2 Compression Algorithms |title=The Comprehensive R Archive Network |date=22 September 2015 |publisher=r-project.org |chapter-url=https://cran.r-project.org/web/packages/brotli/vignettes/brotli-2015-09-22.pdf}}.{{rp|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.

The Brotli specification was generalized in September 2015 for HTTP stream compression (content-encoding type "br"). This generalized iteration also improved the compression ratio by using a predefined dictionary of frequently used words and phrases. 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.

The Internet Engineering Task Force approved the Brotli compressed data format specification as an informational request for comment ({{IETF RFC|7932}}) in July 2016.{{citation |last1=Alakuijala |first1=Jyrki |last2=Szabadka |first2=Zoltan |title=RFC 7932: Brotli Compressed Data Format |series=Internet Engineering Task Force Request for Comments |year=2016 |location=Fremont, CA |publisher=IETF Trust}}. The Brotli data format is an integral part of the 2nd iteration of the Web Open Font Format,{{rp|3}} which was recognized in a 2021 Technology & Engineering Emmy Award from the National Academy of Television Arts & Sciences for font technology standardization at W3C.{{Cite web |date=2022-06-01 |title=W3C Receives Emmy Award for Standardizing Font Technology |url=https://www.w3.org/blog/news/archives/9514}}{{Cite web |date=2022-06-01 |title=Changing the face of the web: W3C Web Fonts Working Group and MPEG recognized with a Technology & Engineering Emmy Award |url=https://www.w3.org/2022/04/pressrelease-woff-emmyaward.html.en}}

Brotli support has been added over the years to web browsers, with 96% of worldwide users using a browser that supports the format, as of July 2022.{{Cite web |date=2022-06-28 |title=Can I use... - Brotli |url=https://caniuse.com/brotli}}

In 2016 Dropbox reimplemented Brotli in Rust to fulfill their requirement to be more secure against a malicious client.[https://dropbox.tech/infrastructure/lossless-compression-with-brotli Lossless compression with Brotli in Rust for a bit of Pied Piper on the backend], Daniel Reiter Horn and Mehant Baid, 2016-06-29.[https://dropbox.tech/infrastructure/-broccoli--syncing-faster-by-syncing-less], Rishabh Jain and Daniel Reiter Horn, 2020-08-04

Algorithm

Brotli's new file format allows its authors to improve upon Deflate by 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.

Unlike most general-purpose compression algorithms, Brotli uses a predefined dictionary, roughly 120 KiB in size, in addition to the dynamically populated ("sliding window") dictionary. The predefined dictionary contains over 13000 common words, phrases and other substrings derived from a large corpus of text and HTML documents.{{citation |last=Chirgwin |first=Richard |chapter=Google's new squeeze: Brotli compression open-sourced |title=The Register |date=September 23, 2015 |publisher=theregister.co.uk |chapter-url=https://www.theregister.co.uk/2015/09/23/googles_brotli_compression_opensourced }}. Using a predefined dictionary has been shown to increase compression where a file mostly contains commonly used words.{{cite book |doi=10.1109/CIT.2007.22 |chapter=Word Indexing for Mobile Device Data Representations |title=7th IEEE International Conference on Computer and Information Technology (CIT 2007) |pages=399–404 |year=2007 |last1=Larkin |first1=Henry |isbn=978-0-7695-2983-7 |s2cid=8707991}}.

Brotli's sliding window is limited to 16 MiB. This enables decoding on mobile phones with limited resources, but makes Brotli underperform on compression benchmarks having larger files. The constraints of the small window size can be alleviated by using Large Window Brotli, which is not compatible with RFC 7932 (Brotli proper).{{cite web |last1=Kliuchnikov |first1=Eugene |title=How to use large window sizes? · Issue #639 · google/brotli |url=https://github.com/google/brotli/issues/639 |website=GitHub |language=en |quote=Currently we are testing "Large Window Brotli" extension that will allow up to 1GiB window. [...] "Large Window Brotli" is landed.}}

Name

While Google's zopfli implementation of the deflate compression algorithm is named after Zöpfli, the Swiss German word for a snack-sized braided buttery bread, brotli is named after Brötli, the Swiss German word for a bread roll.{{citation |last=Szabadka |first=Zoltan |date=September 22, 2015 |chapter=Introducing Brotli: a new compression algorithm for the internet |title=Google Open Source Blog |chapter-url=https://opensource.googleblog.com/2015/09/introducing-brotli-new-compression.html |location=Mountain View, CA |publisher=opensource.googleblog.com}}. 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,{{rp|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.{{citation |last=Adler |first=Mark |date=Jan 26, 2015 |chapter=Brotli specification review and verification |title=Adler brotli |chapter-url=https://github.com/madler/brotli/blob/master/README |location=San Francisco |publisher=GitHub}}. Other implementations of the specification also exist, including one in the source-to-source Haxe language.

Applications

Brotli compression is generally used as an alternative to gzip on the web, as Brotli provides better overall compression.{{Cite web |last=Calvano |first=Paul |date=2018-07-25 |title=Brotli Compression: How Much Will It Reduce Your Content? |url=https://paulcalvano.com/2018-07-25-brotli-compression-how-much-will-it-reduce-your-content/ |access-date=2021-03-07}} Compared to gzip compression, JavaScript files compressed with Brotli are roughly 15% smaller, HTML files are around 20% smaller, and CSS files are around 16% smaller.{{Cite web |last=Pandjarov |first=Hristo |date=2021-01-13 |title=More Site Speed Gains with Brotli Compression Algorithm |url=https://www.siteground.com/blog/brotli-compression/ |access-date=2021-03-07 |website=SiteGround}}

The reference implementation does ship a command-line program {{code|brotli}} similar to {{code|gzip}},{{cite web |title=brotli(1) manual page |url=https://manned.org/brotli.1 |website=manned.org}} but use in the Unix-like world as a simple compressor is scarce. Libarchive developers find the raw stream format of .br files difficult to support, as there is no magic number to indicate the file format.{{cite web |title=Brotli support · Issue #1238 · libarchive/libarchive |url=https://github.com/libarchive/libarchive/issues/1238#issuecomment-529746683 |website=GitHub |language=en |quote=Without a magic signature, libarchive cannot automatically recognize the file type, so it cannot automatically decompress. (Libarchive does not consider the file name, only the contents.)}}

Industry support

= Browsers and other clients =

  • Mozilla Firefox introduced support for the "br" content-encoding method in version 44 (released on 26 January 2016).{{Citation|chapter = Firefox 44 release notes|chapter-url = https://www.mozilla.org/en-US/firefox/44.0/releasenotes/|last=Goodger|first=Ben|display-authors=et al|date=26 January 2016|title=Mozilla Firefox|publisher = Mozilla Foundation}}.
  • Google Chrome has supported the "br" content-encoding method since version 50 (released on 20 April 2016).{{citation|first=Kenji|last=Baheux|date=15 January 2016|chapter=Accept-encoding: br on HTTPS connection|title=Chrome Platform Status|chapter-url=https://www.chromestatus.com/feature/5420797577396224|publisher=chromestatus.com}}.
  • 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).{{citation|chapter-url=https://blogs.windows.com/msedgedev/2016/12/20/introducing-brotli-compression|chapter=Introducing Brotli compression in Microsoft Edge|title=Microft Edge Developer|last=Trace|first=Rob|date=December 20, 2016|publisher=blogs.windows.com}}
  • Safari has supported the "br" content-encoding method since version 11 (released on 5 October 2017).
  • cURL has a compile-time option to support the "br" content-encoding method using libbrotli as of version 7.57, released on 29 November 2017.{{cite web|last1=Stenberg|first1=Daniel|display-authors=et al|title=curl - Changes|url=https://curl.haxx.se/changes.html#7_57_0|website=curl.haxx.se|access-date=14 January 2018}}
  • 7zip is available extended with Brotli by 7zip-zstd.{{Cite web|url=https://github.com/mcmilk/7-Zip-zstd|title=README|website=GitHub|date=15 October 2021}}
  • PeaZip supports Brotli .BR format for compression and extraction{{Cite web|url=https://peazip.github.io/brotli-compression-utility.html|title = Google Brotli: How to compress, open, extract BR files}}

= Web servers =

  • For Apache HTTP Server, the "br" content-encoding method has been supported by the [https://httpd.apache.org/docs/2.4/mod/mod_brotli.html mod_brotli] module since version 2.4.26.{{Citation|chapter = Changes with Apache 2.4.26 | title=Apache HTTPD repository|chapter-url=https://svn.apache.org/repos/asf/httpd/httpd/tags/2.4.26/CHANGES|publisher=svn.apache.org}}.
  • Microsoft IIS has a supported extension since May 2018 that adds support for the "br" content-encoding method.{{cite web|url=https://docs.microsoft.com/en-us/iis/extensions/iis-compression/iis-compression-overview#higher-compression-ratio-with-brotli-compression|title=Higher Compression Ratio with Brotli compression|date=6 Oct 2023}}
  • Microsoft Azure Front Door can dynamically compress content on the edge using Brotli{{cite web|url=https://docs.microsoft.com/en-us/azure/frontdoor/front-door-caching#file-compression|title=Caching with Azure Front Door|website=docs.microsoft.com|date=15 June 2023 }} since its launch on April 17, 2019.{{cite web|url=https://azure.microsoft.com/en-us/updates/azure-front-door-service-is-now-available|title=Azure Front Door Service is now available|website=azure.microsoft.com}}
  • nginx has a [https://github.com/google/ngx_brotli 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.
  • Amazon CloudFront can automatically compress cacheable responses at the edge using Brotli, as of September 2020.{{cite web |url=https://aws.amazon.com/about-aws/whats-new/2020/09/cloudfront-brotli-compression/ |title=Amazon CloudFront announces support for Brotli compression |website=aws.amazon.com}}
  • LiteSpeed Web Server has included the "br" content-encoding method for static files only since version 5.2 in July 2017.
  • Cloudflare CDN offers a brotli option to compress data between its edge node and the user.{{cite web |url=https://support.cloudflare.com/hc/en-us/articles/200168396-What-will-Cloudflare-compress- |title=What will Cloudflare compress? |website=support.cloudflare.com}}
  • NaviServer [https://web.archive.org/web/20181101015345/https://bitbucket.org/naviserver/naviserver/src/tip/NEWS?at=default&fileviewer=file-view-default added support] in version 4.99.17b1
  • Caddy serves statically compressed .br files since version 0.9.4 from December 21, 2016.
  • lighttpd mod_deflate supports .br since 1.4.56{{cite web|url=https://redmine.lighttpd.net/projects/lighttpd/wiki/Release-1_4_56|title=lighttpd 1.4.56 release info|website=redmine.lighttpd.net}} from November 2020.

References

{{reflist|30em}}

;Notes

{{refbegin}}

:{{nbsp}}-{{nbsp}} {{citation|last=Finley|first=Klint|date=22 September 2015|title=Hooli, I Mean Google, Gives Away Compression Code for Free|journal=Wired Online|url=https://www.wired.com/2015/09/hooli-mean-google-gives-away-compression-code-free/|publisher=wired.com}}.

{{refend}}