We just shipped support for the ugliest part of HTTP: Vary

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

Cloudflare now honours the Vary header for non-image content, so developers can serve HTML and JSON from one URL without risking cached responses going to the wrong client.

Read this as

Cloudflare has shipped support for the HTTP 'Vary' header, a mechanism a web server uses to tell a caching service to store separate copies of a page depending on request details. Previously Cloudflare ignored Vary except for images, so sites serving HTML to browsers and JSON to other programs from one URL risked caching one version and delivering it to the wrong audience. Willison had wanted this for years. He personally avoids the pattern, adding a .json suffix instead, but it affects developers using content negotiation.

Cloudflare's caching edge network now honours the HTTP Vary header beyond images, closing a long-standing gap that made single-URL content negotiation risky: a cached JSON response could be served to a browser expecting HTML. Teams that already rely on this pattern can now deploy behind Cloudflare safely. Simon Willison notes he avoids the pattern entirely, using a .json suffix, so the change's practical audience is existing content-negotiation users. No pricing or rollout details are given.

The classic content-negotiation failure mode: servers respond to 'Accept: text/html' with HTML and otherwise with JSON, and caches must key on that via the Vary header. Cloudflare previously ignored Vary on anything other than images, so caching such an endpoint risked cross-format cache pollution. The new support fixes that. Willison instead prefers predictable per-format URLs (.json suffix) and gives no benchmark or configuration detail on the shipped feature.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

Cloudflare Vary header HTTP Hacker News Datasette Pyodide

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading

datasette-charts 0.5a0

Datasette Charts 0.5a0 adds calendar heatmaps, box plots and active-over-time charts, enabling richer data visualisation directly in the browser without extra libraries.