From c44377f0f103c2f17805d9e0bf4d2688e962af5e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 6 Nov 2026 22:13:27 -0700 Subject: 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 --- build.js | 5 +++-- 1 file 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(); })()); }); -- cgit v1.2.3