Skip to content

Commit 67073d5

Browse files
committed
fix: Pre-cache default translations on service worker install
1 parent b3347be commit 67073d5

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

public/service-worker.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,32 @@ const APP_SHELL = [
1717

1818
self.addEventListener("install", (event) => {
1919
event.waitUntil(
20-
caches
21-
.open(APP_CACHE)
22-
.then((cache) =>
23-
cache
24-
.addAll(APP_SHELL)
25-
.catch((err) =>
26-
console.warn(
27-
"[SW] Pre-cache failed, will rely on dynamic caching:",
28-
err,
20+
Promise.all([
21+
caches
22+
.open(APP_CACHE)
23+
.then((cache) =>
24+
cache
25+
.addAll(APP_SHELL)
26+
.catch((err) =>
27+
console.warn(
28+
"[SW] Pre-cache failed, will rely on dynamic caching:",
29+
err,
30+
),
2931
),
30-
),
31-
),
32+
),
33+
caches
34+
.open(TRANSLATIONS_CACHE)
35+
.then((cache) =>
36+
cache
37+
.addAll(["./translations/en.json"])
38+
.catch((err) =>
39+
console.warn(
40+
"[SW] Translation pre-cache failed, will rely on dynamic caching:",
41+
err,
42+
),
43+
),
44+
),
45+
]),
3246
);
3347
self.skipWaiting();
3448
});

0 commit comments

Comments
 (0)