-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
46 lines (41 loc) · 1.48 KB
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js');
// Cache your HTML pages using a cache-first strategy with versioning
workbox.routing.registerRoute(
/\.(html)$/,
new workbox.strategies.CacheFirst({
cacheName: 'NostrNet-html-pages-v1.1', // Update the cache name with versioning
})
);
workbox.routing.registerRoute(
/\.(css|js|png|jpg|jpeg|gif|svg|ico)$/,
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'NostrNet-static-assets-v1.1', // Update the cache name with versioning
})
);
workbox.routing.registerRoute(
/https:\/\/icon\.horse\/icon\//,
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'IconHorse-api-v1.1', // Update the cache name with versioning
})
);
workbox.precaching.precacheAndRoute([
// Precache your HTML pages with versioning
{ url: '/index.html', revision: 'v1' },
{ url: '/assets/pages/wallet/wallet.html', revision: 'v1' },
{ url: '/assets/pages/backup/backup.html', revision: 'v1' },
{ url: '/assets/pages/control/control.html', revision: 'v1' },
// Update revision numbers for other assets
]);
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheName.startsWith('NostrNet') && !cacheName.includes('v1.2')) {
return caches.delete(cacheName);
}
})
);
})
);
});