Network & PerformanceBaseline · Newly

Brotli & Compression Dictionaries

Mental Model

Brotli (br) beats gzip by 15–25% on JS and CSS using a built-in static dictionary of common web tokens. Compression Dictionary Transport (dcb/dcz) goes further: the browser feeds your cached app.v1.js into the decompressor so app.v2.js transfers as a tiny delta.

Interactive Simulator

Payload Transfer: Gzip vs Brotli vs Dictionary Delta

Adjust bundle delta ratio and Brotli quality to observe wire bytes and compression CPU latency.

Parameter Profile
brotliQuality5
useSharedDictionaryOn
payloadKindstatic-js-bundle
brotliQuality
5
useSharedDictionary
On
payloadKind
static-js-bundle
Parameters evaluated in real time.

Under the Hood

Standard compression treats every hashed bundle (app.v2.js) as a brand-new stranger, forcing users to re-download 98% unchanged code. Shared dictionaries work like git diff over HTTP: the HTTP Cache supplies app.v1.js as a reference window, and the server only streams the bytes that changed.

  1. On the initial fetch, the server sends Use-As-Dictionary: match="/assets/app.*.js" alongside a cacheable response.
  2. On the next deploy, the client advertises Available-Dictionary: :<sha256>: and Accept-Encoding: gzip, br, dcb, dcz over HTTP/2 & HTTP/3.
  3. The CDN or build pipeline compresses app.v2.js against v1 and returns Content-Encoding: dcb with Vary: Available-Dictionary.
HTTP
# Response 1: register cached bundle as a dictionary
Use-As-Dictionary: match="/assets/app.*.js", id="app-v1"
Cache-Control: public, max-age=31536000, immutable

# Response 2: delta-compressed update
Content-Encoding: dcb
Vary: Available-Dictionary, Accept-Encoding

Problem Genealogy

  • 1996 (RFC 1952 Gzip): DEFLATE over HTTP cut text sizes dramatically, but lacked a pre-trained web vocabulary.
  • 2015 (RFC 7932 Brotli): Embedded a 120 KB static dictionary of HTML/CSS/JS tokens, becoming the default for static assets, at the cost of slow level-11 encoding.
  • 2024+ (RFC 9842 Compression Dictionaries): Standardized Use-As-Dictionary, ending the curse of 1-line bugfixes invalidating 400 KB bundles.

Production Pitfalls

Production Pitfall
  • Brotli quality 11 on dynamic SSR: Running max-quality Brotli on uncached HTML stalls TTFB on the origin CPU; pre-compress static files at level 11 and cap dynamic responses at level 4–5.
  • Missing Vary: Available-Dictionary: Without Vary, a CDN caches a dcb binary diff and serves it to first-time visitors who lack the base dictionary.
When Not to Use
  • When not to use compression: Already-compressed binary formats (woff2, avif, webp, mp4) only waste CPU cycles and can actually grow slightly when re-compressed.

Connections & Logical Next Steps

Network & PerformanceBrotli & Compression Dictionaries
What This Unlocks
Leaf concept