home-app/public/sw.js

58 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-04-30 13:12:41 +00:00
importScripts("workbox/workbox-sw.js");
self.addEventListener("install", (e) => {
self.skipWaiting();
2022-04-29 15:32:11 +00:00
});
if (workbox) {
2022-04-30 13:12:41 +00:00
workbox.core.setCacheNameDetails({
prefix: "home-app",
suffix: "0.0.3",
precache: "precache",
runtime: "runtime",
});
workbox.routing.registerRoute(
/\/assets/,
new workbox.strategies.CacheFirst({
plugins: [
new workbox.expiration.Plugin({
maxAgeSeconds: 24 * 60 * 60,
2022-04-29 15:32:11 +00:00
}),
2022-04-30 13:12:41 +00:00
],
cacheName: "assets",
})
);
workbox.routing.registerRoute(
"/manifest.json",
new workbox.strategies.StaleWhileRevalidate({
plugins: [
new workbox.expiration.Plugin({
maxAgeSeconds: 7 * 24 * 60 * 60,
2022-04-29 15:32:11 +00:00
}),
2022-04-30 13:12:41 +00:00
],
cacheName: "assets",
})
);
workbox.routing.registerRoute(
"/",
new workbox.strategies.StaleWhileRevalidate({
plugins: [
new workbox.expiration.Plugin({
maxAgeSeconds: 60 * 60 * 24,
2022-04-30 03:10:50 +00:00
}),
2022-04-30 13:12:41 +00:00
],
cacheName: "assets",
})
);
workbox.routing.registerRoute(
/\**/,
new workbox.strategies.StaleWhileRevalidate({
plugins: [
new workbox.expiration.Plugin({
maxAgeSeconds: 60 * 60 * 24,
2022-04-29 15:32:11 +00:00
}),
2022-04-30 13:12:41 +00:00
],
cacheName: "assets",
})
);
2022-04-29 15:32:11 +00:00
}