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. Lisez 3 points de vue avec leurs éléments à l’appui et les liens vers les sources.

En un coup d’œil

  • Longstanding desire for Vary header support

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

    Lire le moment probant · Paragraphe 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.

    Lire le moment probant · Paragraphe 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.

    Lire le moment probant · Paragraphe 5

Passages clés3

Passages attribués et accompagnés du contexte nécessaire à leur vérification. Ouvrez le texte original pour vérifier la source.

API design preference

Preference for URL-based content negotiation over Accept headers

Extrait original

(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

Extrait original

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.

Source et méthodologie

Ces points de vue renvoient à leurs sources originales. Les reformulations sont signalées et ne sont pas des citations mot à mot.

Ouvrir la transcription ou les documents sources (s’ouvre dans un nouvel onglet)Signaler un problème