-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsw.js
More file actions
57 lines (54 loc) · 1.38 KB
/
sw.js
File metadata and controls
57 lines (54 loc) · 1.38 KB
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
52
53
54
55
56
57
const cacheName = 'cache-v1';
const precacheResources = [
'/',
'index.html',
'recorder.html',
'instructions.html',
'viewer.html',
'viewer.js',
'lib/bootstrap-4.5.3.css',
'lib/jquery-3.5.1.js',
'lib/bootstrap-4.5.3.js',
'lib/jquery-ui.css',
'lib/jquery-1.12.4.js',
'lib/jquery-ui.js',
'jszip/vendor/FileSaver.js',
'jszip/documentation/css/pygments.css',
'jszip/documentation/css/main.css',
'jszip/dist/jszip.js',
'p5/p5.js',
'howlerjs/howler.js',
'pdfjs/pdf.js',
'pdfjs/pdf.worker.js',
'player/pdfRender.js',
'player/getdata.js',
'player/sketch.js',
'recorder/pdfRender.js',
'recorder/audio.js',
'recorder/sketch.js',
'recorder/saveData.js',
'lib/jquery-1.9.1.js'
];
self.addEventListener('install', event => {
console.log('Service worker install event!');
event.waitUntil(
caches.open(cacheName)
.then(cache => {
return cache.addAll(precacheResources);
})
);
});
self.addEventListener('activate', event => {
console.log('Service worker activate event!');
});
self.addEventListener('fetch', event => {
console.log('Fetch intercepted for:', event.request.url);
event.respondWith(caches.match(event.request)
.then(cachedResponse => {
if (cachedResponse) {
return cachedResponse;
}
return fetch(event.request);
})
);
});