diff options
| author | Adam Soltys <[email protected]> | 2026-11-06 22:13:27 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-06 22:13:27 -0700 |
| commit | c44377f0f103c2f17805d9e0bf4d2688e962af5e (patch) | |
| tree | 15994b74e5cf1d89a592f1a260ba7637ecffba5b | |
| parent | efbc15065d78b1bbc0a841b628faf3f6b23ee0a0 (diff) | |
| download | coinosv3-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.js | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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(); })()); }); |
