-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
28 lines (26 loc) · 720 Bytes
/
Copy pathsw.js
File metadata and controls
28 lines (26 loc) · 720 Bytes
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
var staticUrls = [
'./',
'./index.html',
'./styles.css',
'./leaflet.css',
'./leaflet.js'
]
self.addEventListener('install', function(event){
console.log('[Service Worker] Install');
event.waitUntil(
caches.open('pwaTutorialCache')
.then(function(cache){
console.log('[Service Worker] Caching Static Files');
return cache.addAll(staticUrls);
})
);
});
self.addEventListener('fetch', function(event){
console.log('[Service Worker] Fetch');
event.respondWith(
caches.match(event.request)
.then(function(response){
return response || fetch(event.request);
})
);
});