We just shipped support for the ugliest part of HTTP: Vary
Cloudflare now honors HTTP Vary, avoiding HTML and JSON cache mixups.
Simon Willison commented on Cloudflare shipping support for the HTTP Vary header in its cache. He notes that content negotiation on Accept previously risked storing a JSON response and later serving it to a client that expected HTML, because Cloudflare ignored Vary except for images. He says he still prefers distinct URLs that predictably return HTML or JSON.
- Cloudflare caching now honors the HTTP Vary header beyond images.
- Ignoring Vary could cache JSON and later serve it to HTML clients.
- Willison still prefers separate URLs that always return HTML or JSON.
From the original article
My comment on We just shipped support for the ugliest part of HTTP: Vary — Hacker News. 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.
simonwillison.net
A short excerpt; the article and its images belong to the publisher. Summary, key facts and assessment above are AI-written from the article and can be wrong.