Skip to content

Commit 1d903c9

Browse files
committed
perf(web-ui): add assets service worker cache
1 parent c8b1513 commit 1d903c9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

services/web-ui/src/serviceWorker.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ workbox.setConfig({
1111

1212
// workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);
1313

14+
// Assets
15+
workbox.routing.registerRoute(
16+
new RegExp(".html$"),
17+
new workbox.strategies.NetworkFirst({
18+
cacheName: "assets-cache",
19+
plugins: [
20+
new workbox.expiration.ExpirationPlugin({
21+
maxEntries: 50, // Limit number of images cached
22+
maxAgeSeconds: 1 * 24 * 60 * 60, // 1 day
23+
}),
24+
],
25+
})
26+
);
27+
1428
// Images
1529
workbox.routing.registerRoute(
1630
new RegExp("s3."),
@@ -19,7 +33,7 @@ workbox.routing.registerRoute(
1933
plugins: [
2034
new workbox.expiration.ExpirationPlugin({
2135
maxEntries: 50, // Limit number of images cached
22-
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
36+
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
2337
}),
2438
],
2539
})

0 commit comments

Comments
 (0)