-
Notifications
You must be signed in to change notification settings - Fork 3
/
sw2.js
51 lines (40 loc) · 1.14 KB
/
sw2.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
50
51
'use strict';
const PRECACHE = 'precache-v104e';
const RUNTIME = 'runtime';
const offlineUrl = '/offline.html';
// A list of local resources we always want to be cached.
const PRECACHE_URLS = [
// Home
'/',
'/Themes/Giggle/css/ballpit.css',
'/manifest.json',
'/Themes/default/scripts/script.js',
'/Themes/Giggle/svg/fplus-symbol.svg',
'/Themes/Giggle/scripts/ballpit.js',
'/Themes/Giggle/svg/snake4.svg',
// Offline screen
'/Themes/Giggle/svg/offline-snake.svg',
'/Themes/Giggle/css/offline.css',
offlineUrl
];
// The install handler takes care of precaching the resources we always need.
self.addEventListener('install', event => {
event.waitUntil(
caches.open(PRECACHE)
.then(cache => cache.addAll(PRECACHE_URLS))
.then(self.skipWaiting())
);
});
/*
self.addEventListener('fetch', function(event) {
if (event.request.mode === 'navigate' || (event.request.method === 'GET' && event.request.headers.get('accept').includes('text/html'))) {
event.respondWith(
fetch(event.request.url).catch(error => {
return caches.match(offlineUrl);
})
);
} else {
return response
}
});
*/