跳到正文
原文
Simon Willison·· 26 天前AI 评分5

Cloudflare 支持 HTTP Vary 头功能

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

AI 导读

Cloudflare 于 2026 年 9 月 23 日推出对 HTTP Vary 头的支持,解决了用户代理发送不同接受类型时,内容缓存和错误服务的问题。

原文

23rd September 2026

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.)

来源:Simon Willison · simonwillison.net