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
|
const CACHE_NAME = 'lut-cam-cache-v1';
const urlsToCache = [
'/',
'./',
'index.html',
'lut.js',
'service-worker.js',
'android-icon-192x192.png',
'android-icon-512x512.png',
'favicon.ico',
'favicon-16x16.png',
'favicon-32x32.png',
'favicon-96x96.png',
'apple-icon-57x57.png',
'apple-icon-60x60.png',
'apple-icon-72x72.png',
'apple-icon-76x76.png',
'apple-icon-114x114.png',
'apple-icon-120x120.png',
'apple-icon-144x144.png',
'apple-icon-152x152.png'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => {
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request)
.then(response => {
if (response) {
return response;
}
return fetch(event.request);
})
);
});
|