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

Simon Willison's Weblog ·

A commentary by Simon Willison on Cloudflare's newly added support for the HTTP Vary header, noting his longstanding desire for it, describing prior caching limitations where Cloudflare ignored Vary for non-image responses, and stating his personal preference for URL-based content negotiation over Accept-header–based approaches. Lies 3 Standpunkte mit Belegen und Links zu den Originalquellen.

Auf einen Blick

  • Longstanding desire for Vary header support

    Simon Willison has wanted Cloudflare to support the HTTP Vary header for years.

    Unterstützendes Moment lesen · Absatz 2
  • Cloudflare previously ignored Vary for non-image responses

    Before the new feature, Cloudflare ignored the Vary header on responses other than images, risking incorrect cache sharing—e.g., caching a JSON response and serving it to a client expecting HTML.

    Unterstützendes Moment lesen · Absatz 4
  • Preference for URL-based content negotiation over Accept headers

    Simon Willison independently chose not to use Accept-header–based content negotiation, preferring predictable URLs—for example, using a '.json' suffix to serve JSON.

    Unterstützendes Moment lesen · Absatz 5

Wichtige Passagen3

Zugeordnete Passagen mit dem Kontext zur Überprüfung. Öffnen Sie den Originaltext, um die Quelle zu prüfen.

API design preference

Preference for URL-based content negotiation over Accept headers

Originalauszug

(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 caching limitations

Cloudflare previously ignored Vary for non-image responses

Originalauszug

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.

Quelle & Methodik

Diese Standpunkte sind mit ihren Originalquellen verknüpft. Paraphrasen sind gekennzeichnet und keine wörtlichen Zitate.

Transkript oder Quellenmaterial öffnen (wird in einem neuen Tab geöffnet)Ein Problem melden