Compression

HTTP compression shrinks text files such as HTML, CSS and JavaScript on the server before they travel, and the browser restores them on arrival without loss.

What it is

CompressionEncoding a file so that it needs fewer bytes in transit, after which the browser decodes it. The server names the method in the Content-Encoding header, usually gzip, Brotli or Zstandard.In the glossary finds repetition in a file and stores it more compactly. HTTP compression is lossless: after unpacking, the browser has exactly the original file. In the request header Accept-Encoding the browser lists the methods it understands; the server picks one and names it in the response header Content-Encoding. Three methods matter today. The oldest, gzipThe long-established compression format of the web, specified in RFC 1952. Every browser understands it, so it remains the fallback when a browser offers nothing newer.In the glossary, has been the common default for decades. BrotliA lossless compression format developed at Google and specified in RFC 7932. For text files such as HTML, CSS and JavaScript it usually produces smaller files than gzip.In the glossary, standardised as RFC 7932 in 2016, carries a built-in dictionary of frequent words and code fragments and compresses web text considerably better than gzip. Zstandard (zstd)A lossless compression format developed at Meta (then Facebook) and specified in RFC 8878. The browser announces in its Accept-Encoding header whether it understands zstd, so a server can fall back to Brotli or gzip.In the glossary, specified in RFC 8878, is designed for fast compression at ratios equal to or better than gzip.

Why it matters

Text files are what the browser needs first: it cannot draw the page before it has the HTML and the stylesheets. Markup and code contain a great deal of repetition, and MDN puts the reduction at up to 70 percent for some documents. The cost is a little computing time on the server, which makes compression one of the cheapest gains in web performance.

Adoption is broad but uneven. Of the mobile requests that CDNs delivered compressed in 2025, 46 percent used Brotli, 42 percent gzip and 12 percent Zstandard, up from 3 percent a year earlier. Requests served directly by origin servers still used gzip in 61 percent of cases (Web Almanac 2025).

What to look for

Only text benefits. JPEG, WebP, AVIF, video and WOFF2The W3C font format for the web. It compresses font data with Brotli, so a WOFF2 file is considerably smaller than the same font as TTF or OTF.In the glossary fonts are already compressed, and compressing them again costs processing time and can even make them larger. The first check on any website is therefore whether the server compresses text at all, which the Content-Encoding header of a response shows.

Files that never change between visits can be compressed once, at the highest setting, when the site is built. Pages that a server generates per request need a faster setting, because the highest Brotli level takes considerably longer. When responses are cached, the server must also send Vary: Accept-Encoding, so that a browser never receives a version it cannot unpack.

Brotli works in every current browser. Chrome has supported Zstandard since version 123 and Firefox since version 126; Safari supports it only in part on the desktop. A server offering Zstandard therefore keeps Brotli or gzip as an alternative.