-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmwb.js
More file actions
24 lines (21 loc) · 691 Bytes
/
Copy pathmwb.js
File metadata and controls
24 lines (21 loc) · 691 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
importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js');
const
cachename = 'mapworkbox',
expconfig ={
maxEntries: 250,
maxAgeSeconds: 120
},
pruner = new workbox.expiration.Plugin(expconfig),
precacheController = new workbox.precaching.PrecacheController(cachename);
self.addEventListener('activate', (event) => {
event.waitUntil(precacheController.activate());
});
self.addEventListener('message', (event) => {
if (event.data.type === 'CACHE_URLS') {
const tocache = event.data.payload.urlsToCache;
precacheController.addToCacheList(tocache);
precacheController.install({
plugins: [pruner]
});
}
});