forked from blurymind/tilemap-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
28 lines (25 loc) · 707 Bytes
/
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
const cacheName = "1629829956916";
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open(cacheName).then((cache) => cache.addAll([
'/tilemap-editor/',
'/tilemap-editor/index.html',
'/tilemap-editor/src/tilemap-editor.js',
'/tilemap-editor/src/styles.css',
])),
);
});
self.addEventListener('message', (e) => {
if (e.data.action === 'skipWaiting') {
self.skipWaiting();
}
});
self.addEventListener('fetch', (e) => {
if (e.request.url.match( /^.*(imgur=).*$/) ) {
return false;
}
console.log(e.request.url);
e.respondWith(
caches.match(e.request).then((response) => fetch(e.request) || response),
);
});