Why my CSS changes weren't showing up (and the one-line fix)
styles.css?v=2, and bump it every time you change the file.
The symptom
I added new diagrams to this site and uploaded both the HTML and the updated styles.css. The new HTML showed up straight away, but the diagrams looked broken because the page was still using the old stylesheet.
Why it happens
Cloudflare caches static files like CSS, JavaScript and images at its edge servers by default, so visitors get them faster. Your browser keeps its own copy too. That's great for speed, but it means a changed file with the same name can keep being served from cache for a while.
The fix
Change the URL, not just the file. Adding a query string makes browsers and Cloudflare treat it as a brand-new file:
<link rel="stylesheet" href="styles.css?v=2">
Every time I change the stylesheet, I bump the number: ?v=3, ?v=4 and so on. The file on the server keeps the same name; only the reference changes.
Other options
- Purge the cache in Cloudflare (Caching → Configuration). Works, but it's a manual step every time.
- Development Mode in Cloudflare temporarily bypasses the cache while you're making lots of changes.
- Ctrl + F5 clears your own browser's copy, but does nothing for your visitors.
What I took away from it
Caching problems look like "my change didn't save". When something should have updated and didn't, ask what's sitting between me and the server before assuming the file is wrong.