aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2016-01-19 22:56:27 +0100
committerMatěj Cepl <mcepl@cepl.eu>2016-01-19 22:56:27 +0100
commit025cb34ccfb0ad48321d91e9cba5692267a9997d (patch)
tree23efe9be05812ac08a90d9dfb4b13f5c9549e1ce
parentc5e1bc43a8e3c5b607f907e0460072e71e5d1856 (diff)
downloadhesla-025cb34ccfb0ad48321d91e9cba5692267a9997d.tar.gz
Another broken attempt of working SW
-rw-r--r--sworker.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/sworker.js b/sworker.js
index ca2deb1..9d991ad 100644
--- a/sworker.js
+++ b/sworker.js
@@ -1,4 +1,4 @@
-var version = 'v19 - 2016-01-19';
+var version = 'v28 - 2016-01-19';
var toCache = [
'/',
'index.html',
@@ -15,28 +15,31 @@ var toCache = [
'icon-30.png',
'icon-60.png',
'index_de.html',
- 'index.html',
'require.js',
'screen.css'
];
self.addEventListener('install', event => {
- event.waitUntil(
- caches.open('static' + version).then(c => c.addAll(toCache));
- );
+ event.waitUntil(
+ caches.open('static' + version)
+ .then(
+ c => c.addAll(toCache)
+ .then(v => console.log('Yay!'), e => console.log('Error'))
+ )
+ );
});
self.addEventListener('activate', event => {
- event.waitUntil(
- Promise.all(caches.keys().then(
- keys => keys.filter(key => key != 'static' + version).
+ event.waitUntil(caches.keys().then(
+ keys => Promise.all(
+ keys.filter(key => key != 'static' + version).
map(key => caches.delete(key))
)
)
);
});
-self.addEventListener('fetch', event => {
+self.addEventListener('fetch', function(event) {
event.respondWith(caches.match(event.request));
});