Cloudflare serves the HTML with max-age=0 and everything else with max-age=14400. The filenames are not content hashed — klotski.js is always klotski.js — so for four hours after a deploy a device that already has the bundle answers from its own disk and never learns there is a new one. The HTML revalidates and points at the same URL it always did. The service worker does not save it. It is network-first, which is the right shape and reads as though it would, but its `fetch` goes through the same HTTP cache: "network" was already answering from disk. Nothing in the app can see past that, which is why this is a header and not a code change. So a _headers file, and max-age=0 with must-revalidate for everything. That is not "do not cache" — the copy is kept and its ETag revalidates it, so a file that has not changed costs a conditional request and a 304 with no body. Offline stays the service worker's job, and it still holds its own copy of every core asset. The alternative is hashing the bundle's name, which is the better answer for a big app and the wrong shape for this one: index.html is checked in on purpose so somebody can read it, and hashed names mean generating it again.
- commit
- dbdf91b9aa60aa03365455085b53c0972ca952c6
- parent
- 7906417dea964b0b722c4cfd6847888f9cb8a399
- author
- Dami <dami.etoile@gmail.com>
| A | assets/ | 17 | +++++++++++++++++ |
@@ -0,0 +1,17 @@
1+# Cloudflare Pages reads this file and it decides whether a deploy reaches a2+# device that already has the app.3+#4+# The default it applies to everything but the HTML is `max-age=14400`: four5+# hours during which the browser answers from its own cache without asking. That6+# is a promise this build cannot keep, because the filenames are not content7+# hashed — klotski.js is always klotski.js — so a device that fetched the bundle8+# in the last four hours keeps running the old one after a deploy. The service9+# worker cannot save it either: the worker is network-first, but its `fetch` goes10+# through this very cache, so "network" was already answering from disk.11+#12+# max-age=0 with must-revalidate is not "do not cache". The copy is kept and the13+# ETag revalidates it, so an unchanged file costs a conditional request and a 30414+# with no body. Being offline is the service worker's job, and it still has its15+# own copy of everything.16+/*17+ Cache-Control: public, max-age=0, must-revalidate