Spaces:
Running
on
Zero
Running
on
Zero
Update service-worker.js
Browse files- service-worker.js +12 -21
service-worker.js
CHANGED
@@ -1,22 +1,13 @@
|
|
1 |
-
const CACHE_NAME = 'pawmatch-v1';
|
2 |
-
const urlsToCache = [
|
3 |
-
'/',
|
4 |
-
'/index.html',
|
5 |
-
'/assets/icon-192.png',
|
6 |
-
'/assets/icon-512.png',
|
7 |
-
'/manifest.json'
|
8 |
-
];
|
9 |
-
|
10 |
self.addEventListener('install', (event) => {
|
11 |
event.waitUntil(
|
12 |
-
caches.open(
|
13 |
-
.
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
);
|
21 |
});
|
22 |
|
@@ -24,10 +15,10 @@ self.addEventListener('fetch', (event) => {
|
|
24 |
event.respondWith(
|
25 |
caches.match(event.request)
|
26 |
.then((response) => {
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
return
|
31 |
})
|
32 |
);
|
33 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
self.addEventListener('install', (event) => {
|
2 |
event.waitUntil(
|
3 |
+
caches.open('pawmatch-v1').then((cache) => {
|
4 |
+
return cache.addAll([
|
5 |
+
'./',
|
6 |
+
'./manifest.json',
|
7 |
+
'./assets/icon-192.png',
|
8 |
+
'./assets/icon-512.png'
|
9 |
+
]);
|
10 |
+
})
|
11 |
);
|
12 |
});
|
13 |
|
|
|
15 |
event.respondWith(
|
16 |
caches.match(event.request)
|
17 |
.then((response) => {
|
18 |
+
return response || fetch(event.request);
|
19 |
+
})
|
20 |
+
.catch(() => {
|
21 |
+
return caches.match('./');
|
22 |
})
|
23 |
);
|
24 |
});
|