Skip to content
AnswerWell geo Documentation

Research · 10 min read · Answerwell

Response Compression Rules, Algorithms, and Shared Dictionaries

How HTTP response compression works on a CDN: Compression Rules, Gzip and Brotli, Zstandard, shared dictionaries, and verifying Content-Encoding.

This page summarises Cloudflare documentation on content compression: what happens between your origin, the Cloudflare network, and visitors; how Compression Rules override defaults; and how shared dictionaries (RFC 9842) delta-compress versioned assets when the origin implements them. Browser guidance from Chrome DevTools and Google crawlers is included where it aligns with checking Accept-Encoding and Content-Encoding.

Content compression: origin, edge, and browser

Section titled “Content compression: origin, edge, and browser”

Cloudflare compresses content in two places: between Cloudflare and website visitors, and between Cloudflare and your origin server.

Cloudflare compresses content in two ways: between Cloudflare and your website visitors and between Cloudflare and your origin server.

— Cloudflare, Content compression

Visitors advertise support with the Accept-Encoding request header; the response should name the algorithm in Content-Encoding. For text assets, smaller payloads mean faster loads—browsers and performance audits expect this pattern.

When a browser requests a resource, it will use the Accept-Encoding HTTP request header to indicate what compression algorithms it supports.

— Google Chrome, Enable text compression

Your server should return the Content-Encoding HTTP response header to indicate what compression algorithm it used.

— Google Chrome, Document request latency

On the edge, Cloudflare can apply Gzip, Brotli, and Zstandard to visitors (Zstandard is enabled through Compression Rules). Toward the origin, Cloudflare requests Brotli or Gzip only.

Default compression to visitors: plans, types, and limits

Section titled “Default compression to visitors: plans, types, and limits”

Which algorithms and content types get compressed

Section titled “Which algorithms and content types get compressed”

If the visitor’s browser supports them, Cloudflare may return Gzip-, Brotli-, or Zstandard-encoded responses for a long list of text and web asset types (HTML, CSS, JavaScript, JSON, SVG, fonts, WASM, and others). See the full list in Content compression — Compression between Cloudflare and website visitors.

What actually gets applied depends on the visitor’s Accept-Encoding, your plan, and any matching Compression Rules.

Factor Behaviour
Plan default (visitor leg) Free: Zstandard by default; Pro/Business: Brotli; Enterprise: Gzip (Content compression)
Visitor header Algorithm must appear in the visitor’s Accept-Encoding
HTTP status Successful responses: compressed only on 200; errors: only on 403 or 404
Minimum size Gzip: 48 bytes; Brotli and Zstandard: 50 bytes — smaller bodies stay uncompressed

Cloudflare will only apply compression to responses with a minimum size when sending them to website visitors: For Gzip, responses must have a minimum size of 48 bytes. For Brotli and Zstandard, responses must have a minimum size of 50 bytes. Smaller responses will not be compressed, regardless of their content type.

— Cloudflare, Content compression

Accept-Encoding: what visitors send vs what Cloudflare sends upstream

Section titled “Accept-Encoding: what visitors send vs what Cloudflare sends upstream”

Toward visitors, Cloudflare honours the visitor’s Accept-Encoding when choosing how to respond (Content compression). For requests Cloudflare makes to your origin, behaviour differs: the platform overwrites the incoming value for the origin fetch.

For incoming requests, the value of this header will always be set to accept-encoding: br, gzip. If the client set a different value, such as accept-encoding: deflate, it will be overwritten and the original value will be available in request.cf.clientAcceptEncoding.

— Cloudflare, HTTP headers — Accept-Encoding

On all plans, Cloudflare requests content from the origin server using the accept-encoding: br, gzip header.

— Cloudflare, Content compression

Common conclusion: Tune compression for browsers with Compression Rules and origin cache headers; do not assume the Accept-Encoding your origin logs for visitor requests is the same header Cloudflare uses on origin pulls—check request.cf.clientAcceptEncoding when you need the client’s original value.

Compression Rules: when to customise edge compression

Section titled “Compression Rules: when to customise edge compression”

What Compression Rules do and how they match

Section titled “What Compression Rules do and how they match”

Use Compression Rules to customise compression on responses from Cloudflare’s network to visitors, by file extension and content type. Rules use the Ruleset Engine; the zone’s DNS records must be proxied through Cloudflare.

When a compression rule matches and lists several compression algorithms (such as gzip and Brotli), Cloudflare selects the first algorithm from your list that the visitor’s browser supports. Cloudflare determines browser support from the accept-encoding HTTP request header, which browsers send automatically to indicate which compression formats they can decompress. If multiple compression rules match the same request, the last matching rule takes precedence.

— Cloudflare, Compression Rules

Compression Rules with Zstandard support are available on all plans (Free access rolled out gradually per the rules changelog).

Compression options: algorithms and fallbacks

Section titled “Compression options: algorithms and fallbacks”

Settings are documented in Compression Rules settings. Summary:

Option Purpose
Enable Brotli and Gzip Default edge behaviour: Brotli preferred, then Gzip or uncompressed
Enable Zstandard (Beta) Prefer Zstd, fallback to Brotli, Gzip, or none
Disable compression No compression for matching requests; also disables default compression
Custom Explicit order: Gzip, Brotli, Zstandard, Auto, or Default

If you list only Gzip, Brotli, or Zstandard with no fallback and the browser supports none of them, the response is uncompressed. Add Auto to the list for a fallback (Compression Rules settings — Custom).

Via API, rules use action compress_response in phase http_response_compression, with action_parameters.algorithms entries such as gzip, brotli, zstd, none, auto, default (Compression Rules settings — API configuration). Create rules in the dashboard or API.

Examples in the docs include disabling Brotli, disabling compression for AVIF, Zstandard for default content types, Gzip for CSV, and Brotli only for a path — see the examples gallery.

Chrome performance guidance vs Cloudflare defaults

Section titled “Chrome performance guidance vs Cloudflare defaults”

Chrome’s Lighthouse audit recommends Brotli when the browser supports br, with Gzip as fallback—aligned with letting the edge prefer modern algorithms when rules allow.

If the browser supports Brotli (br) you should use Brotli because it can reduce the file size of the resources more than the other compression algorithms.

— Google Chrome, Enable text compression

On Cloudflare Pro/Business, default visitor compression already prefers Brotli; Free plans default to Zstandard unless you change behaviour with Compression Rules (Content compression, enable Zstandard example).

Common conclusion: Prefer the strongest algorithm the client supports (br, zstd, then gzip), configured explicitly with Custom algorithm order when defaults do not match your policy.

Origin compression, recompression, and cache-control

Section titled “Origin compression, recompression, and cache-control”

Passing through origin compression to visitors

Section titled “Passing through origin compression to visitors”

When the origin responds with Brotli or Gzip and a correct content-encoding header, Cloudflare can keep that encoding for the visitor if the browser supports it and no feature rewrites the body (Content compression — from origin servers). The proxy can also convert between compressed and uncompressed formats independently of caching.

Broken origin compression (wrong Content-Length, corrupt gzip) is a frequent pain point; Cloudflare suggests disabling origin compression and letting the edge compress (HTTP/2 — Compression issues).

cache-control: no-transform and body-modifying features

Section titled “cache-control: no-transform and body-modifying features”

cache-control: no-transform from the origin blocks Cloudflare from altering compression and preserves origin Content-Length (Content compression — Content-Length). With no-transform present on a cached asset, compression is disabled: compressed origin assets stay compressed; uncompressed assets are not compressed at the edge (Origin Cache Control — Gzip and Other Compression).

Even with the same algorithm end to end, Cloudflare decompresses and recompresses when features such as Automatic HTTPS Rewrites, Polish, Rocket Loader, Email Address Obfuscation, or RUM are enabled (Content recompression). Disable those features on specific paths with configuration rules where needed.

Shared dictionaries: delta compression through the edge

Section titled “Shared dictionaries: delta compression through the edge”

What shared dictionaries are and who implements them

Section titled “What shared dictionaries are and who implements them”

Shared dictionaries (RFC 9842) let the origin compress a response against a resource the browser already cached so only the delta crosses the network—useful for versioned JavaScript, CSS, and framework chunks after deploys.

Shared dictionaries (RFC 9842 ↗︎) let your origin compress a response against a copy of the same — or a different — resource that the visitor’s browser already has cached. Only the difference between the two resources travels over the wire.

— Cloudflare, Shared dictionaries

Cloudflare shared dictionaries passthrough (open beta on all plans per the changelog) forwards dictionary headers and dcb/dcz encodings without recompressing; the origin manages dictionaries and deltas.

Your origin manages the dictionary lifecycle: deciding which assets are dictionaries, attaching Use-As-Dictionary headers, and producing deltas in response to Available-Dictionary requests. Cloudflare handles the transport and the cache.

— Cloudflare, Shared dictionaries passthrough now in open beta

In passthrough mode Cloudflare:

  • Forwards Use-As-Dictionary and Available-Dictionary unchanged
  • Treats dcb (dictionary Brotli) and dcz (dictionary Zstandard) as valid Content-Encoding end to end
  • Varies the cache key on Available-Dictionary and Accept-Encoding

All of the following must be true (Shared dictionaries — Requirements):

  • Browser supports compression dictionary transport (e.g. Chrome 130+, Edge 130+), with dcb or dcz in Accept-Encoding
  • Browser sends Available-Dictionary when it has a dictionary
  • Origin returns Content-Encoding: dcb or dcz and Vary: Accept-Encoding, Available-Dictionary
  • HTTPS, same origin per RFC 9842
Header / encoding Direction Role
Use-As-Dictionary Origin → browser Marks a response usable as a dictionary for future URLs (WHATWG URL Pattern)
Available-Dictionary Browser → origin SHA-256 hash of cached dictionary (:base64hash: syntax)
dcb / dcz Origin → browser Delta-compressed body against that dictionary
  1. In the dashboard: Speed → Settings → Content Optimization → toggle Shared Dictionaries on (Shared dictionaries — Enable passthrough).

  2. Or PATCH zone setting shared_dictionary_mode to passthrough:

    curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/settings/shared_dictionary_mode" \
    --request PATCH \
    --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    --json '{"value": "passthrough"}'
  3. On the origin: send Use-As-Dictionary on first responses for versioned assets; on later requests with Available-Dictionary, respond with dcb/dcz and required Vary (mark assets, compress against dictionary).

  4. When no dictionary applies, fall back to normal Brotli, Zstandard, or Gzip (fall back).

Set shared_dictionary_mode to disabled to strip dictionary headers and stop caching dcb/dcz variants. The setting is a zone setting and is not compatible with Cloudflare Version Management for in-version toggles (Shared dictionaries — Enable passthrough).

Google’s crawlers accept gzip, deflate, and Brotli, advertised per request:

Google’s crawlers and fetchers support the following content encodings (compressions): gzip, deflate, and Brotli (br). The content encodings supported by each Google user agent is advertised in the Accept-Encoding header of each request they make. For example, Accept-Encoding: gzip, deflate, br.

— Google, Overview of Google crawlers and fetchers

That is separate from shared-dictionary encodings (dcb/dcz), which target supporting browsers, not generic crawler Accept-Encoding lists.

  • Assuming the origin sees the browser’s full Accept-Encoding — Cloudflare sends br, gzip to the origin; use request.cf.clientAcceptEncoding for the client value (HTTP headers).
  • Custom rule with a single algorithm and no Auto — Unsupported browsers get uncompressed responses (only Brotli for a path).
  • no-transform without understanding trade-offs — Edge optimisations and Compression Rules that alter the body are skipped; compression may not be applied to uncompressed assets (Origin Cache Control, Compression Rules remarks).
  • Enabling passthrough but not implementing origin deltas — No bandwidth win until the origin emits dcb/dcz (Shared dictionaries).
  • Leaving Polish/Rocket Loader on for dictionary-compressed JS — Triggers decompress/recompress or breaks delta paths (Content recompression, Shared dictionaries — Limitations).
  • Compressing tiny responses — Bodies under 48–50 bytes are never compressed at the edge (Content compression).
  1. Open Chrome DevTools → Network, load the page, select an HTML or JS request, and confirm Response Headers include content-encoding (br, zstd, or gzip).

  2. Enable large request rows in the Network panel and compare transferred size (compressed) to resource size (uncompressed) for the same request (Check for response compression).

  3. In Cloudflare, review matching Compression Rules (last matching rule wins) and Content compression defaults for your plan.

  4. If using shared dictionaries, run the two-request curl recipe in Test shared dictionaries and confirm the second response has Content-Encoding: dcz or dcb and a much smaller Content-Length.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.