Native HTTP Compression Algorithms in Chromium

This article provides a concise breakdown of the compression algorithms natively supported within the HTTP content decoding pipeline of the Chromium web browser. It covers legacy standards like Gzip and Deflate alongside modern, high-performance algorithms such as Brotli and Zstandard, explaining how Chromium utilizes each to reduce bandwidth consumption and accelerate web page loading.

When Chromium requests a resource from a web server, it advertises its supported decompression capabilities using the Accept-Encoding HTTP header. The server then compresses the response using one of the mutually supported methods and declares the chosen algorithm in the Content-Encoding header. Chromium’s network stack processes this incoming data stream through its internal decoding pipeline before passing the decompressed bytes to the renderer.

Currently, Chromium natively supports four primary compression algorithms in its HTTP pipeline.

1. Gzip (gzip and x-gzip)

Gzip is the most widely adopted compression algorithm on the web and serves as the universal baseline in Chromium.

  • Mechanism: It is based on the DEFLATE algorithm, which uses a combination of LZ77 (Lempel-Ziv 1977) dictionary coding and Huffman coding.
  • Implementation: Chromium uses an optimized fork of the zlib library to decode Gzip streams. It recognizes both the standard gzip token and the legacy x-gzip token in the Content-Encoding header.
  • Availability: Supported across both HTTP and HTTPS connections.

2. Deflate (deflate)

Deflate is an older standard that uses the same underlying compression mechanics as Gzip but differs in how the data is wrapped.

  • Mechanism: Technically, the HTTP deflate encoding refers to the zlib data format (RFC 1950) encapsulating compressed DEFLATE data (RFC 1951).
  • Implementation: Historically, many web servers misconfigured deflate by sending raw, unwrapped DEFLATE streams without the zlib header. To maintain compatibility, Chromium’s decoding pipeline automatically detects whether a zlib header is present and seamlessly falls back to raw DEFLATE decoding if it is missing.
  • Availability: Supported across both HTTP and HTTPS connections.

3. Brotli (br)

Developed by Google, Brotli is a modern compression algorithm designed specifically for the web, offering significantly better compression ratios than Gzip for text-based assets like HTML, CSS, and JavaScript.

  • Mechanism: Brotli uses a combination of a modern variant of the LZ77 algorithm, Huffman coding, and second-order context modeling. Crucially, it utilizes a predefined static dictionary of common words, phrases, and HTML/JS tokens.
  • Implementation: Chromium integrates the native C Brotli decoder directly into its network stack.
  • Availability: Chromium only advertises and supports Brotli over secure contexts (HTTPS/TLS). This restriction exists because legacy intermediary proxies over unencrypted HTTP often fail to recognize the br token and corrupt the payload.

4. Zstandard (zstd)

Developed by Meta, Zstandard is a real-time compression algorithm that was enabled by default starting in Chromium 123. It is designed to offer compression ratios comparable to Brotli but with significantly faster decompression speeds.

  • Mechanism: Zstandard combines a dictionary-matching stage (LZ77) with a large search window and an entropy-coding stage that uses Finite State Entropy (tANS) and Huffman coding.
  • Implementation: Chromium uses the official zstd reference library within its network service to decode streams in real time, reducing CPU overhead on the client device during page loads.
  • Availability: Like Brotli, Chromium restricts Zstandard support to secure contexts (HTTPS) to prevent interference from outdated network middleboxes.

Summary of the Decoding Pipeline

On a standard, secure connection, Chromium sends the following header to initiate the pipeline: Accept-Encoding: gzip, deflate, br, zstd

If the connection is insecure (HTTP), Chromium downgrades the header to prevent proxy corruption: Accept-Encoding: gzip, deflate

Additionally, Chromium supports the identity token, which indicates that no compression has been applied to the payload, bypassing the decoding filters entirely.