-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
35 lines (33 loc) · 833 Bytes
/
sw.js
File metadata and controls
35 lines (33 loc) · 833 Bytes
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
// Simple service worker for offline support
self.addEventListener('install', event => {
self.skipWaiting();
event.waitUntil(
caches.open('yahudim-app-v1').then(cache => {
return cache.addAll([
'/',
'/index.html',
'/assets/index.generated.css',
'/assets/index-D4sASlS8.js',
'/manifest.json',
// Add more assets as needed
]);
})
);
});
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(keys =>
Promise.all(
keys.filter(key => key !== 'yahudim-app-v1').map(key => caches.delete(key))
)
)
);
self.clients.claim();
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request).then(response => {
return response || fetch(event.request);
})
);
});