fix for SW
Some checks failed
ci / site (push) Has been cancelled
publish-image / publish (push) Has been cancelled

This commit is contained in:
2026-02-10 18:02:37 -05:00
parent 57ad560b01
commit daac2eec20

View File

@@ -5,7 +5,7 @@
*/ */
// Bump this value on deploy to invalidate caches. // Bump this value on deploy to invalidate caches.
const CACHE_VERSION = "v3"; const CACHE_VERSION = "v4";
const CACHE_SHELL = `shell-${CACHE_VERSION}`; const CACHE_SHELL = `shell-${CACHE_VERSION}`;
const CACHE_PAGES = `pages-${CACHE_VERSION}`; const CACHE_PAGES = `pages-${CACHE_VERSION}`;
@@ -13,6 +13,9 @@ const CACHE_MEDIA = `media-${CACHE_VERSION}`;
const SHELL_ASSETS = ["/", "/styles/global.css", "/favicon.png", "/robots.txt"]; const SHELL_ASSETS = ["/", "/styles/global.css", "/favicon.png", "/robots.txt"];
// Cache.addAll() throws if there are any duplicate requests.
const SHELL_ASSETS_UNIQUE = Array.from(new Set(SHELL_ASSETS));
// Keep media cache bounded so we don't grow indefinitely. // Keep media cache bounded so we don't grow indefinitely.
const MAX_MEDIA_ENTRIES = 80; const MAX_MEDIA_ENTRIES = 80;
@@ -58,7 +61,7 @@ self.addEventListener("install", (event) => {
event.waitUntil( event.waitUntil(
(async () => { (async () => {
const cache = await caches.open(CACHE_SHELL); const cache = await caches.open(CACHE_SHELL);
await cache.addAll(SHELL_ASSETS); await cache.addAll(SHELL_ASSETS_UNIQUE);
// Activate new worker ASAP to pick up new caching rules. // Activate new worker ASAP to pick up new caching rules.
await self.skipWaiting(); await self.skipWaiting();
})(), })(),