I fixed a bug on my downloader site last month. I uploaded the fix, opened the page, and it worked. The button did what it was supposed to do, the layout was right, everything looked fine. Then a visitor messaged me: the old version was still there.

I had not broken the fix. I had not uploaded the wrong file. The fix was live — just not live for them. That afternoon taught me more about caching than any tutorial had, and now flushing the CDN is the last step of every single upload I do on ramrom.io.

Two caches sit between my upload and a visitor

The first is the browser cache. When someone visits a page, their browser keeps copies of the CSS, the JavaScript and sometimes the page itself, so the next visit is fast. That is normally a good thing. It becomes a problem the moment I change one of those files, because the browser has no reason to ask for the new one until its copy expires.

The second is the CDN cache. My host serves static files through edge servers around the world. A visitor in Karachi does not fetch my stylesheet from the same machine a visitor in Berlin does. Each edge server keeps its own copy, and each copy has its own expiry time. So after an upload, some visitors get the new file and some get the old one, depending on which edge server answers them.

That is exactly what happened to me. My browser had fetched the page fresh, and the edge server nearest me had the new file. The visitor's browser and their edge server were both still serving the old one. We were both right about what we saw, and we were looking at two different versions of the same site.

Cache-busting helps, but only halfway

I already used ?v= query strings on my scripts and stylesheets. Change the file, bump the number, and the browser treats it as a brand new file. That works well for assets, and it is still part of every upload I do.

What it does not fix is the HTML page itself. A ?v= on a script does nothing if the visitor's cached copy of the page still points at the old script name. The page is the thing the CDN caches too, and it is the thing people actually look at.

So my upload checklist now has a fixed order. Assets first, then pages, then the version numbers on anything that changed, and finally the CDN flush in my host's dashboard. The flush tells every edge server to drop its cached copies. It takes a minute or two, and after it I verify from the outside, not from my own browser.

How I check now

My own browser is the worst tool for this job, because it has seen the site a thousand times. I check with curl -I and look at the cache headers — the age header and the cache status tell me whether the response came from the edge or from the origin server. Then I open the page in a private window, and I check it once on mobile data instead of my home Wi-Fi, because that is a different network and often a different edge server.

If the new version shows up in all three places, the fix is live. If it shows up in one and not the others, I wait for the flush to finish propagating and check again. What I never do any more is upload a fix, glance at my own screen, and call it done.

The rule I kept

A fix is not live when I can see it. A fix is live when a stranger's browser can see it. Everything between those two moments is caching, and on a small site with a CDN in front of it, that gap is real. The flush button is small and boring, but it is the difference between "I fixed it" and "it is actually fixed" — and I press it after every upload now, even the tiny ones.