-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
49 lines (39 loc) · 1.08 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
47
48
49
const CACHE_NAME = `TaskTopia:0.1`;
//TODO: Reimplement cache when done with everything
// Use the install event to pre-cache all initial resources.
self.addEventListener('install', event => {
event.waitUntil((async () => {
/*
const cache = await caches.open(CACHE_NAME);
cache.addAll([
'/',
'/main.js',
'/style.css'
]);
*/
})());
});
self.addEventListener('fetch', event => {
event.respondWith((async () => {
/*
const cache = await caches.open(CACHE_NAME);
// Get the resource from the cache.
const cachedResponse = await cache.match(event.request);
if (cachedResponse) {
return cachedResponse;
} else {
try {
// If the resource was not in the cache, try the network.
*/
const fetchResponse = await fetch(event.request);
// Save the resource in the cache and return it.
//cache.put(event.request, fetchResponse.clone());
return fetchResponse;
/*
} catch (e) {
// The network failed.
}
}
*/
})());
});