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. Read 3 viewpoints with supporting evidence and source links.

Understand this piece

3 key points

Synthesis

  1. Longstanding desire for Vary header support

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

    Supporting evidence 1

    Original excerpt

    I've been wanting this from Cloudflare for years .

    Simon Willison · Paragraph 2

    Read in source context →
  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.

    Supporting evidence 1

    Original excerpt

    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.

    Simon Willison · Paragraph 4

    Read in source context →

    Continue exploring

    CDN caching limitations →
  3. 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.

    Supporting evidence 1

    Original excerpt

    (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 · Paragraph 5

    Read in source context →

    Continue exploring

    API design preference →

Key passages3

Attributed passages with the context to verify them. Open the original text to check the source.

API design preference

Preference for URL-based content negotiation over Accept headers

Original excerpt

(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

Original excerpt

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.

Mentioned here

All mentioned things

Cloudflare

Mention only

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

Read supporting evidence · Simon Willison

Source & methodology

These viewpoints are linked to their original sources. Paraphrases are labeled and are not verbatim quotes.

Open transcript or source material (opens in a new tab)Report an issue

Explore these viewpoints by person