-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsw.js
86 lines (83 loc) · 2.39 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const CACHE_NAME = 'v1_cache_anilox_manager',
urlsToCache = [
'./login.html',
'./js/login.js',
'./css/login.css',
'./registro.html',
'./css/registro.css',
'./js/registro.js',
'./css/style.css',
'./controllers/autenticacion.js',
'./anilox-detail.html',
'./ayuda.html',
'./export-data.html',
'./index.html',
'./listado.html',
'./print-report.html',
'./upload-file.html',
'./css/anilox-detail.css',
'./css/ayuda.css',
'./css/export-data.css',
'./css/index.css',
'./css/listado.css',
'./css/print-report.css',
'./css/upload-file.css',
'./js/anilox-detail.js',
'./js/ayuda.js',
'./js/common.js',
'./js/export-data.js',
'./js/index.js',
'./js/listado.js',
'./js/print-report.js',
'./js/upload-file.js',
'https://fonts.googleapis.com/css2?family=Rajdhani:wght@300;400;500;600;700&display=swap',
'https://fonts.googleapis.com/icon?family=Material+Icons+Sharp',
'./assets/favicon.ico',
'./assets/anilox-placeholder.jpg',
'./assets/logo-placeholder.svg',
'./assets/navbar-background.jpg',
'./assets/icons/./manifest-icon-192.maskable.png',
'./assets/icons/./manifest-icon-512.maskable.png',
'./assets/logo.png',
'./utils/anillox-analysis.js',
'./utils/anillox-history.js',
'./utils/anillox-list.js',
'./utils/client-info.js',
];
self.addEventListener('install', e=>{
e.waitUntil(
caches.open(CACHE_NAME)
.then(cache =>{
return cache.addAll(urlsToCache)
.then(() => self.skipWaiting())
})
.catch(err => console.warn(err))
);
});
self.addEventListener('activate', e=>{
const cacheWhitelist = [CACHE_NAME];
e.waitUntil(
caches.keys()
.then(cacheNames => {
cacheNames.map(cacheName => {
if(cacheWhitelist.indexOf(cacheName) === -1){
return caches.delete(cacheName);
}
})
})
.then(() => self.clients.claim())
.catch(err => console.warn(err))
);
});
self.addEventListener('fetch', e=>{
e.respondWith(
caches.match(e.request)
.then(res => {
if(res){
return res;
}
return fetch(e.request);
})
.catch(err => console.warn(err))
);
});