Hacker News

New stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. The worst VGA monitor ever made – Tandy VGM-225(youtube.com)
    discuss
  2. Understanding Tetrode Screen Current(robkalmeijer.nl)
    discuss
  3. Six-year-old breaks women's world Rubik's Cube record [video](youtube.com)
    discuss
  4. An extension that finds things you've never searched, from your own history(microsoftedge.microsoft.com)
    discuss
  5. It's not your imagination – dating has gotten more combative lately(vox.com)
    1comments
  6. Moderna announced that their cancer mRNA vaccine succeeded in a late-stage trial(bbc.com)
    discuss
  7. Sign Up for Tweet.app(tweet.app)
    discuss
  8. SpaceX given unique access to classified DoD space tracking data, sources say(breakingdefense.com)
    discuss
  9. Treating the APK as a database: a decompiler 269x faster than JADX(medium.com/droidasc)
    discuss
  10. Katamari Object Library(andrew-boylan.com)
    5comments
  11. Book Review: Steve Jobs in Exile by Geoffrey Cain(lapcatsoftware.com)
    discuss
  12. antigravity-seo: Go engine and token-efficient SEO audits for Antigravity CLI(github.com/angelotc)
    discuss
  13. Meta's New Muse AI Agent Read My Private Messages. I Never Asked It To(inc.com)
    discuss
  14. Tattoos as a risk factor for lymphoma: a population-based case–control study(thelancet.com)
    discuss
  15. Level Designers Will Love My Engine, Here's Why [video](youtube.com)
    discuss
  16. Eric Schmidt on the era of AI warfare(economist.com)
    discuss
  17. OpenAI agent 'infiltrated' Australian government website, PM says(bbc.com)
    1comments
  18. DoorDash's $131.5M Settlement with the City of New York(doordash.com)
    discuss
  19. 'Rex Jr.' Could Be Most Important T. Rex Ever Discovered(cowboystatedaily.com)
    discuss
  20. TSA is rolling out a new scanner – it could be a headache for carry-on travelers(independent.co.uk)
    discuss
  21. Contrastive Language Models(contrastive-lm.notion.site)
    2comments
  22. Trump White House Press Ban Matches 1933 Nazi Law(flyingpenguin.com)
    discuss
  23. Universities Must Reinvent Themselves for the Intelligent Age(time.com)
    discuss
  24. Nori LLM: Achieving Over 1M tok / s(noriagentic.com)
    discuss
  25. An Undercover Google Analyst Infiltrated a Notorious Supply-Chain Hacking Gang(wired.com)
    discuss
  26. A 13-Year-Old Has Been Cured of DIPG, the Deadliest Childhood Brain Cancer(imapac.com)
    1comments
  27. ThinkingCap-Qwen3.8-27B: the same answers, 37% less thinking(bottlecapai.com)
    discuss
  28. China's Approach to AI(madeinchinajournal.com)
    discuss
  29. Show HN: Tokenhush – keeps your secrets out of what Claude Code sends(github.com/fregie)
    discuss
  30. 16GB iPod Nano 3G Upgrade(tuckerosman.com)
    discuss

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

108 pointsby 7h agoblog.cloudflare.com
23 comments
5h agoHN ↗

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

2h agoHN ↗

Frankly, the supposed variability of the Accept header never really sat all that well with me; in practice I much prefer working with explicitly versioned endpoints — one of the most infuriating things is having to hardcode "Accept: text/x-myorgname-custom-json-blob-v4" because omitting it would produce "406 Not Acceptable". Bonus points if that's the only Accept header the service would ever accept in all of three years of it working before being decommissioned. Double bonus points if v5 would be introduced behind a separate URI anyway (and it, too, would require precisely "Accept: text/x-myorgname-custom-json-blob-v5" and nothing else).

5h agoHN ↗

Nice to see. I’ve used vary to quite a bit of success on CloudFront back in the day.

I actually assumed when I started using Cloudflare that it did have vary support and it led to a serious bug in my sass app at the time.

5h agoHN ↗

I honestly thought they would never ship this. Holy hell this has been a long time coming.

Actual real content negotiation in 2026. Never thought I'd live to see the day.

5h agoHN ↗

"If the origin response does not include a Vary header, Cloudflare caches the response normally"[1]

"If one response omits it, Cloudflare could cache that response without the variance needed to keep it isolated."[2]

Will that non-Vary cache object front-run any Vary-segmented cache objects?

If so, probably worth adding a snippet rule to ensure every response has a Vary header?

1: https://developers.cloudflare.com/cache/concepts/vary/#how-v...

2: https://blog.cloudflare.com/vary-support/#how-a-response-mov...

4h agoHN ↗

finally. now maybe they'll have time to implement a working unsubscribe on their marketing emails.

4h agoHN ↗

Turns out their marketing can get to you through HN posts…

4h agoHN ↗

I had not actually realized what a mess Vary is.

Wow, sometimes I think it's amazing the web works at all!

4h agoHN ↗

It pains me to think about the important ones like varying on session cookie and authorization headers, and how badly some middleware can confuse things.

We generate custom content for a given authentication context. We definitely want caching at the user agent, but we want the cache keyed by the authenticated identity. Otherwise something like logging out and logging in as a different identity can produce monstrously confused results when an SPA or similar mixes some cached and some fresh responses into one page.

3h agoHN ↗

Cache invalidation, one of the two hard problems in computer science.

I'm sure most people here already knows the joke, but for the lucky 10,000, here's the full joke:

There are only two hard problems in computer science. Naming things, cache invalidation, and off-by-one errors.

1h agoHN ↗

Wait a second, if you decided to become intermediary in the protocol then you are supposed to add value, not take away the features that already exists.

Although its not clear from the article itself, my gut feeling is that some big enough client arm twisted them to support it before they sign the contract again

3h agoHN ↗

Imagine if we actually built a remote application delivery platform instead of cobbling one onto a glorified document reader

4h agoHN ↗

If this surprises you, remember that Cloudflare doesn't cache HTML by default.

3h agoHN ↗

They can't do that because a CMS under Cloudflare needs to be configured to bust the Cloudflare cache when content is edited or the user will see cached content after they edit a page.

3h agoHN ↗

OTOH a CMS that doesn’t send correct cache headers is already broken

2h agoHN ↗

That might be the default configuration if your CMS doesn't return any cache-control headers. But Cloudflare definitely [0] supports must-revalidate and etag or last-modified, which is also probably supported by whatever CMS you're using. HTTP conditional requests are very old and very widely supported.

[0] Okay, my claim is only definite up to my memory of using Cloudflare for a fairly high-traffic circa 2019-2022. I haven't used Cloudflare after that point, but a quick search of their docs shows support

1h agoHN ↗

Right. But if the cache MUST be revalidated every time, it's the same thing as being disabled.

The point of a reverse proxy is to reduce load on the server rendering the page. If you GET, the page is rendered. So in order for etag/last-modified to be effective, the CMS must implement HEAD. If the CMS doesn't implement HEAD or implements it in a way that ends up doing all the work of GET anyway, you just end up with more load than just doing a GET every time.

The funny thing is that the way HTTP is designed the simplest PHP script can do this correctly, because the server must send the headers first, so a PHP script can NOT do the work to generate the HTML until it has sent the correct headers, as they won't be able to change the headers after they start sending the body. In theory, the process could just shut down the instant the first body byte starts being sent and save work in a HEAD request. The problem is that pretty much everything works in a more "clever" way: you have some sort of template engine that generates the whole HTML, a view method that makes the DB calls, etc., and only after all the work is done the HTTP headers are sent. Because this method allows the backend to add/change/remove headers at any point during the process, not just at the start.

Essentially the problem is that CF doesn't know what your server is running, and even an s-maxage=60 is going to look like a bug from the user's perspective if they go to /post?id=123, navigate to /edit-post?id=123, edit the post, go back to /post?id=123 and see the post unchanged.

1h agoHN ↗

A site I work on serves dynamic language content based on the accept-language header. We do this for some pages and others we redirect to i.e /en/page

But we can't cache those dynamic pages since they vary based on accept language. Maybe with this we can

1h agoHN ↗

Wow this brings back memories. Over twenty years ago I added Vary support to various mod_cache submodules for Apache 2.0, and it was way too high a pain to reward ratio. It just uncovered so many user agent bugs and crazy backends. I remember arguments about being able to cache variable based on non-literal virtual headers (e.g. a geo location header), and a crazy request to Vary based on "Date:" ... which makes absolutely no sense. The whole thing was just too clever for its own good. It's no surprise that language selection ended up in URLs (/en-US/..) rather than "Vary: Accept-Lang" features.

1h agoHN ↗

I feel like putting as much as possible in the URL is a good thing anyway. If I send someone a link, I can know it's the same document that shows on their browser as mine.

28m agoHN ↗

I don't understand why en-US and en-GB should be treated as the same. Wouldn't this result in American visitors seeing words like colour since the wrong English page would be served.