Init
This commit is contained in:
49
public/sw.js
Normal file
49
public/sw.js
Normal file
@ -0,0 +1,49 @@
|
||||
importScripts(
|
||||
'workbox/workbox-sw.js',
|
||||
);
|
||||
self.addEventListener('install', (e) => {
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
if (workbox) {
|
||||
workbox.core.setCacheNameDetails({
|
||||
prefix: 'home-app',
|
||||
suffix: '0.0.2',
|
||||
precache: 'precache',
|
||||
runtime: 'runtime',
|
||||
});
|
||||
workbox.routing.registerRoute(
|
||||
/\/assets/,
|
||||
new workbox.strategies.CacheFirst({
|
||||
plugins: [
|
||||
new workbox.expiration.Plugin({
|
||||
maxAgeSeconds: 24 * 60 * 60,
|
||||
}),
|
||||
],
|
||||
cacheName: 'assets',
|
||||
}),
|
||||
);
|
||||
workbox.routing.registerRoute(
|
||||
'/manifest.json',
|
||||
new workbox.strategies.StaleWhileRevalidate({
|
||||
plugins: [
|
||||
new workbox.expiration.Plugin({
|
||||
maxAgeSeconds: 7 * 24 * 60 * 60,
|
||||
}),
|
||||
],
|
||||
cacheName: 'startpage_me',
|
||||
}),
|
||||
);
|
||||
workbox.routing.registerRoute(
|
||||
'/',
|
||||
new workbox.strategies.StaleWhileRevalidate({
|
||||
plugins: [
|
||||
new workbox.expiration.Plugin({
|
||||
maxAgeSeconds: 60 * 60 * 24,
|
||||
}),
|
||||
],
|
||||
cacheName: 'startpage_me',
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user