Cloudflare tames HTTP's ugliest header: Vary
We just shipped support for the ugliest part of HTTP: Vary – Cloudflare Blog

Cloudflare now supports Vary in Cache Rules, letting origins declare which request headers affect a response while customers decide how each is handled. Normalize collapses equivalent values, passthrough preserves exact bytes, and bypass skips caching. The move addresses Vary's core flaw: a cache can be perfectly correct yet nearly useless, as thousands of language preferences collapse into three responses but fragment into thousands of cold entries.
The result is a cache that can be perfectly correct and almost permanently cold (an entry never reused). Identical responses can be scattered across entries that receive too little traffic to remain hot and in cache.
- simonw
I've been wanting this from Cloudflare for years.
The classic problem here is if you do that thing where user agents that send "accept: text/html" get HTML, while user agents that don't get JSON or some other format.
This used to be impossible to deploy behind Cloudflare caching, because they ignored the Vary header on anything other than images - so you risked caching the JSON version and then serving it up to someone who was expecting HTML.
(Independent of the Cloudflare feature I ended up deciding never to use that pattern, because I prefer having URL that predictably returns HTML or JSON - I add a .json suffix to my apps to serve JSON instead.)
- colmmacc
Wow this brings back memories. Over twenty years ago I added Vary support to various mod_cache submodules for Apache 2.0, and it was way too high a pain to reward ratio. It just uncovered so many user agent bugs and crazy backends. I remember arguments about being able to cache variable based on non-literal virtual headers (e.g. a geo location header), and a crazy request to Vary based on "Date:" ... which makes absolutely no sense. The whole thing was just too clever for its own good. It's no surprise that language selection ended up in URLs (/en-US/..) rather than "Vary: Accept-Lang" features.
- tiffanyh
I just wish CF would enable Enterprise functionality to lower (paid) tiers as they promised a year ago yet haven’t delivered on.
https://blog.cloudflare.com/enterprise-grade-features-for-al...
Like Prefetch: https://developers.cloudflare.com/speed/optimization/content...