Cloudflare Cache Rules Now Understand Vary
On September 22, 2026 Cloudflare shipped full Vary support inside Cache Rules — on every plan from Free to Enterprise, configurable through the dashboard, the Rulesets API and Terraform. The headline the company chose, "the ugliest part of HTTP," is not hyperbole. Vary has been the gap that serious caching logic quietly falls into.
The problem: a header that says "it differs" but not how
The idea is simple enough. An origin responds with Vary: Accept-Language, declaring that this URL serves different representations depending on the request's language, so every cache along the path should store one copy per language.
The trouble is that the header names the fields that may matter without saying which differences actually do. A cache has no way to know that en-US, fr;q=0.8 and fr;q=0.8, en-US are the same request, so it stores two entries holding identical bytes. Multiply that by browser quirks, extensions and value ordering, and one response fragments into hundreds of entries — none of which gets enough traffic to stay hot.
Cloudflare's announcement notes that close to 3,000 popular sites vary on four or more fields, with some exceeding 47. Past that point there is no cache left, only an expensive dispatch table. Which explains the prevailing CDN behaviour until now: either ignore Vary, or refuse to cache anything that carries it.
What changed
The new model splits the responsibility. The origin still decides what matters; Cache Rules decide how each header is processed. Every header gets one of three actions:
- normalize — collapse equivalent forms before matching: lowercase values, sort by quality value, strip parameters from nonzero-quality entries, and reduce regional tags (
en-UStoen) unless fully specified. Applies specifically toAccept,Accept-LanguageandAccept-Encoding. - passthrough — preserve the bytes exactly as they arrived, casing, whitespace and ordering included, for cases where the precise value really does select the response.
- bypass — decline to cache when the variation is inherently unpredictable, as with
CookieorUser-Agent.
The substantive shift is that fragmentation becomes a setting rather than a side effect you absorb.
A practical example
Take a storefront serving three languages and two formats. The origin declares its variance:
HTTP/2 200
content-type: text/html; charset=utf-8
vary: Accept-Language, Accept
cache-control: public, max-age=3600And the Cache Rule decides how each header is handled:
{
"action": "set_cache_settings",
"expression": "http.host eq \"shop.example.com\"",
"action_parameters": {
"cache": true,
"vary": {
"default": "bypass",
"headers": {
"accept-language": {
"action": "normalize",
"languages": ["ar", "en", "ru"]
},
"accept": {
"action": "normalize",
"media_types": ["text/html", "application/json"]
},
"cookie": { "action": "bypass" }
}
}
}
}With this in place, a request carrying Accept-Language: ar-SA, en-US;q=0.9, *;q=0.1 normalizes to ar for matching, so every Arabic-speaking visitor shares one entry instead of one per regional variant. Setting default to bypass ensures that any header not named explicitly cannot quietly reintroduce fragmentation.
Real-world caveats
- No automatic purge. Changing the Vary configuration does not invalidate stored entries; old variants live on until they expire or are purged by hand.
- Origin consistency is a precondition. If the origin returns different
Varyheaders across cacheable responses for the same URL, matching logic and selection logic drift apart — a class of bug that is painful to trace. - normalize changes what the origin receives. The normalized
AcceptandAccept-Languagevalues are forwarded upstream, so any origin logic that depends on the full regional tag needs review. - *`Vary: ` always bypasses**, since it declares that something unmeasurable from the request determines the response.
- Limits: 50 headers per rule, 128 characters per header name, 10 media types in
accept, 20 languages inaccept-language.
Takeaway
Vary itself has not changed, but working with it has moved from "ignore it or lose your cache" to explicit, per-header control. The payoff is largest for multilingual frontends and content-negotiating APIs — precisely the cases that were paying the fragmentation tax in silence. The first step is not writing a rule; it is reading what Vary your origin actually emits today. Most of the time it is broader than it needs to be.
If you build content-negotiating APIs, this is worth reading alongside HTTP's new QUERY method — the cache key is where the two meet.
Primary source: Cloudflare's Vary support announcement and the Cache Rules settings documentation.