fix(build): derive sw.js cache tag from bundle content hash

The service worker uses staleWhileRevalidate on /dist/*, so after a
release it would serve old bundles from cache indefinitely (cache is
only wiped when the cache *name* changes, which was hardcoded to
'dashcaddy-shell-v10'). Result: dashboard appears unchanged after a
self-update until the user manually unregisters the SW.

build.js now hashes the concatenated dist bundles and writes
`dashcaddy-shell-<10-hex-chars>` into sw.js. Any change in dist/
produces a fresh cache name; on the next page load the SW's activate
handler deletes all older caches and the new bundles are fetched.
This commit is contained in:
Sami
2026-05-17 01:41:47 -07:00
parent 3878509fc5
commit ebfc3be9d1
2 changed files with 26 additions and 2 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
const CACHE = 'dashcaddy-shell-v10';
const CACHE = 'dashcaddy-shell-c6600af35d';
const PRECACHE = [
'/',
'/index.html',