From 025cb34ccfb0ad48321d91e9cba5692267a9997d Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 19 Jan 2016 22:56:27 +0100 Subject: Another broken attempt of working SW --- sworker.js | 21 ++++++++++++--------- 1 file 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)); }); -- cgit