评论:我们刚刚发布了对 HTTP 最“丑陋”部分的支持——Vary

Simon Willison's Weblog ·

Simon Willison 对 Cloudflare 新增支持 HTTP Vary 标头的评论,指出他长期以来一直希望获得该功能,描述了此前 Cloudflare 对非图像响应忽略 Vary 的缓存局限性,并陈述了他个人更倾向于基于 URL 的内容协商而非基于 Accept 标头的方法。 阅读 3 条观点,查看支持证据与原始来源。

理解这篇

3 个要点

综合解读

  1. 长期期待 Vary 标头支持

    Simon Willison 多年来一直希望 Cloudflare 支持 HTTP Vary 标头。

    支持这项说法 1

    我多年来一直希望从 Cloudflare 得到这个。

    Simon Willison · 段落 2

    原始摘录
    I've been wanting this from Cloudflare for years .
    回到原文语境 →
  2. 此前忽略非图像响应的 Vary 标头

    新功能上线前,Cloudflare 会忽略图像以外响应的 Vary 标头,存在缓存错误共享的风险——例如将 JSON 响应缓存后返回给期望 HTML 的客户端。

    支持这项说法 1

    这以前无法部署在 Cloudflare 缓存之后,因为他们会忽略图像以外任何内容的 Vary 标头——因此你可能会缓存 JSON 版本,然后将其提供给期望 HTML 的用户。

    Simon Willison · 段落 4

    原始摘录
    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.
    回到原文语境 →
  3. 偏好基于 URL 的内容协商而非 Accept 标头

    Simon Willison 独立决定不使用基于 Accept 标头的内容协商,而偏好可预测的 URL——例如使用“.json”后缀来提供 JSON。

    支持这项说法 1

    (与 Cloudflare 的功能无关,我最终决定永远不采用那种模式,因为我更喜欢能按预期返回 HTML 或 JSON 的 URL——我改为在自己的应用中添加 .json 后缀,以提供 JSON。)

    Simon Willison · 段落 5

    原始摘录
    (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.)
    回到原文语境 →

关键段落3

带明确归属与语境的原文片段。打开原始文本核查出处。

API 设计偏好

偏好基于 URL 的内容协商而非 Accept 标头

(与 Cloudflare 的功能无关,我最终决定永远不采用那种模式,因为我更喜欢能按预期返回 HTML 或 JSON 的 URL——我改为在自己的应用中添加 .json 后缀,以提供 JSON。)

原始摘录
(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.)
CDN 缓存局限性

此前忽略非图像响应的 Vary 标头

这以前无法部署在 Cloudflare 缓存之后,因为他们会忽略图像以外任何内容的 Vary 标头——因此你可能会缓存 JSON 版本,然后将其提供给期望 HTML 的用户。

原始摘录
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.

这里提到的

全部提及对象

Cloudflare

仅提及

Simon Willison 表示,多年来他一直希望 Cloudflare 支持 HTTP Vary 标头。

查看支持证据 · Simon Willison

来源与研究方法

这些观点均关联原始来源。转述已明确标注,不作为逐字原话展示。

打开转录或来源材料 (在新标签页中打开)报告问题