CloudflareZaidoon Abd Al HadiAnnouncement
We just shipped support for the ugliest part of HTTP: Vary
Summary
The Vary response header, often called the ugliest part of HTTP, is now supported in Cache Rules on every Cloudflare plan. Vary tells caches which request fields may affect a response, but not which differences actually matter, leading to cache fragmentation or incorrect responses. For example, a server might deliver different image formats to different browsers, and a cache ignoring Vary risks serving the wrong bytes. The origin still names the request headers that may affect a response, but Cloudflare lets users decide how to handle each one. This support addresses the challenge of balancing correct caching with cache efficiency.
Context
The post explains that the Vary response header, often called the ugliest part of HTTP, is now supported in Cache Rules on every Cloudflare plan. Vary tells caches which request fields may affect a response, but not which differences matter, leading to cache fragmentation or incorrect responses. The post uses an example of a browser requesting HTML and an API client requesting JSON to illustrate the problem.
Takeaways
Vary is a standard HTTP response header that tells intermediary caches which request fields may affect the response sent by the origin.
If a cache ignores Vary, it risks serving the wrong bytes to a request, such as delivering HTML when JSON was requested.
Treating every raw header value as distinct can spread a handful of similar requests into thousands of barely reusable cache entries.
FAQ
What does the Vary header do?
Vary is a standard HTTP response header that tells intermediary caches which request fields may affect the response sent by the origin. It helps caches decide whether to reuse a cached response or fetch a new one based on request differences.
What happens if a cache ignores Vary?
If a cache ignores Vary, it risks serving the wrong bytes to a request, such as delivering HTML when JSON was requested. If it treats every raw header value as distinct, it can create thousands of barely reusable cache entries.
Source and freshness
- Source
- blog.cloudflare.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.