forked from d8ahazard/Phlex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service-worker.js
45 lines (42 loc) · 1.27 KB
/
service-worker.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
importScripts('./js/lib/src/support/12_cache-polyfill.js');
self.addEventListener('install', function (e) {
e.waitUntil(
caches.open('phlex').then(function (cache) {
console.log("opening caches?");
return cache.addAll([
'./css/loader_main.css',
'./css/lib/dist/support.css',
'./css/main_max_400.css',
'./css/main_max_600.css',
'./css/main_min_600.css',
'./css/main_min_2000.css',
'./img/android-icon-36x36.png',
'./img/android-icon-48x48.png',
'./img/android-icon-72x72.png',
'./img/android-icon-96x96.png',
'./img/android-icon-144x144.png',
'./img/android-icon-192x192.png',
'./img/android-icon-384x384.png',
'./img/android-icon-512x512.png',
'./img/apple-icon.png',
'./img/avatar.png',
'./img/favicon.ico',
'./img/phlex-med.png',
'./js/lib/dist/support.js',
'./js/lib/dist/ui.js'
]);
})
);
});
self.addEventListener('fetch', function (event) {
console.log(event.request.url);
event.respondWith(
caches.match(event.request).then(function (response) {
if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') return;
return response || fetch(event.request);
})
);
});
function reload() {
updateStatus(true);
}