HeadlinesBriefing favicon HeadlinesBriefing.com

Cache Rules Now Support HTTP Vary Header Handling

Hacker News •
×

The HTTP Vary response header, described as 'the ugliest part of HTTP that we haven't yet improved,' tells intermediary caches which request fields may affect responses. While considered a 'horrible, kludgy mechanism' with poor interoperability, Vary remains essential for correct caching. When a server delivers different content—like HTML vs JSON—from the same URL, Vary ensures caches don't serve the wrong response to clients requesting different formats.

However, Vary has a fundamental flaw: it specifies which headers may affect responses but not which differences actually matter. For example, two requests with different Accept-Language headers (en-US vs fr;q=0.8) may both map to the same English response, yet caches treat them as distinct variants. This causes cache bloat and inefficiency.

Cloudflare's new Cache Rules feature now provides native Vary support across all plans, allowing administrators to normalize known negotiation headers, pass exact values when differences matter, or bypass cache for unpredictable variations. The origin names the request headers that may affect responses, but you decide how Cloudflare handles each one.