aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-06 22:13:27 -0700
committerAdam Soltys <[email protected]>2026-11-06 22:13:27 -0700
commitc44377f0f103c2f17805d9e0bf4d2688e962af5e (patch)
tree15994b74e5cf1d89a592f1a260ba7637ecffba5b
parentefbc15065d78b1bbc0a841b628faf3f6b23ee0a0 (diff)
downloadcoinosv3-c44377f0f103c2f17805d9e0bf4d2688e962af5e.tar.gz
coinosv3-c44377f0f103c2f17805d9e0bf4d2688e962af5e.zip
A deploy no longer wipes the thumbnail and call caches. The service worker's activation deleted every cache but its own build's, so each deploy (several a day) threw away the media, video and tile thumbnails (each capped at 400/600/1,200 copies) and a call offer waiting for the app; the next launch remade every face and preview from the network. It now removes only older builds' caches (cold-*), keeping the previous one as before
Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--build.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/build.js b/build.js
index 4cb68f3..1a6f097 100644
--- a/build.js
+++ b/build.js
@@ -62,7 +62,7 @@ self.addEventListener('message', (e) => {
// Activating keeps the previous build's cache beside the new one: a page
// launched from the old shell (navigations to / are cache-first, below) keeps
// running the old build until its next launch, and its lazily imported chunks
-// must still be found. Older caches go. Navigation preload starts a
+// must still be found. Older builds' caches go. Navigation preload starts a
// navigation's network request while the worker itself is still starting.
const META = 'coinos-sw-meta';
self.addEventListener('activate', (e) => {
@@ -74,7 +74,8 @@ self.addEventListener('activate', (e) => {
const keep = [CACHE, ...order.filter((k) => k !== CACHE)].slice(0, 2);
await meta.put('cache-order', new Response(JSON.stringify(keep)));
const keys = await caches.keys();
- await Promise.all(keys.filter((k) => k !== META && !keep.includes(k)).map((k) => caches.delete(k)));
+ // only builds' caches: the thumbnail and call caches outlive a deploy
+ await Promise.all(keys.filter((k) => k.startsWith('cold-') && !keep.includes(k)).map((k) => caches.delete(k)));
await self.clients.claim();
})());
});