---
title: "Brotli"
description: "Brotli is Google's lossless compression algorithm that shrinks web assets 15–25% more than gzip. Learn how to enable it on Nginx, Apache and CDNs."
url: "https://nodea.io/en/glossary/brotli"
lang: "en"
updated: "2026-07-13"
---

# Brotli

> Brotli is a lossless compression algorithm developed by Google that shrinks text-based web assets more effectively than gzip and is supported by every modern browser.

**Brotli** is a lossless data-compression algorithm developed at Google and standardized as RFC 7932, designed primarily to make the web faster. It combines a modern LZ77 variant, Huffman coding and context modeling, and its signature feature is a built-in 120 KB dictionary of over 13,000 common strings drawn from natural language, HTML and code — which is why it compresses typical web assets noticeably better than [gzip](https://nodea.io/en/glossary/gzip), usually by 15–25% for text content.

## How Brotli works

Brotli exposes quality levels 0–11; higher levels produce smaller files at the cost of compression time (decompression stays fast throughout). That asymmetry dictates two deployment modes:

- **dynamic compression** — for HTML generated per request, servers use levels 4–6 as a balance between transfer size and CPU load,
- **static pre-compression** — CSS, JavaScript and SVG files are compressed once at build or deploy time at level 11, and the server ships the ready-made *.br* file with zero per-request cost.

Negotiation is standard HTTP content encoding: the browser sends *Accept-Encoding: br, gzip*, the server answers with *Content-Encoding: br*. All modern browsers support Brotli over HTTPS, and gzip remains as a fallback for legacy clients.

## Practical use

Enabling Brotli is one of the cheapest performance wins available: smaller transfers directly improve First Contentful Paint and LCP, lift [PageSpeed](https://nodea.io/en/glossary/pagespeed) scores and cut bandwidth bills. On Nginx it is provided by the *ngx\_brotli* module (*brotli on; brotli\_static on;*), on Apache by *mod\_brotli*, LiteSpeed supports it natively, and most CDNs — Cloudflare, Fastly, CloudFront — compress with Brotli at the edge. On shared hosting, support depends on the platform's server configuration, so it is worth checking before you rely on it.

Compress only text-based content types: HTML, CSS, JS, JSON, SVG, XML and fonts that are not already compressed. Re-compressing JPEG/WebP images, video or archives wastes CPU for zero gain — exclude those MIME types from the configuration.

### Should I replace gzip with Brotli?

Enable Brotli as the preferred encoding and keep gzip as a fallback. Browsers advertise what they accept via the Accept-Encoding header, so the server automatically serves Brotli to modern clients and gzip to legacy ones — you lose nothing by running both.

## Related

- [Gzip](https://nodea.io/en/glossary/gzip)
- [HTTP/2](https://nodea.io/en/glossary/http-2)
- [PageSpeed](https://nodea.io/en/glossary/pagespeed)
- [TTFB](https://nodea.io/en/glossary/ttfb)
- [CDN (Content Delivery Network)](https://nodea.io/en/glossary/cdn)

---

Languages: [pl](https://nodea.pl/pl/slownik-pojec/brotli.md)  
Site index: [llms.txt](https://nodea.io/en/llms.txt)
