diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2016-01-19 22:56:27 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2016-01-19 22:56:27 +0100 |
commit | 025cb34ccfb0ad48321d91e9cba5692267a9997d (patch) | |
tree | 23efe9be05812ac08a90d9dfb4b13f5c9549e1ce | |
parent | c5e1bc43a8e3c5b607f907e0460072e71e5d1856 (diff) | |
download | hesla-025cb34ccfb0ad48321d91e9cba5692267a9997d.tar.gz |
Another broken attempt of working SW
-rw-r--r-- | sworker.js | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -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)); }); |