fix for SW
This commit is contained in:
@@ -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();
|
||||||
})(),
|
})(),
|
||||||
|
|||||||
Reference in New Issue
Block a user