Created
October 13, 2015 18:55
-
-
Save digitarald/950b94312240c8a279c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cache-then-network/sw.js b/cache-then-network/sw.js | |
index 9449f5f..8170159 100644 | |
--- a/cache-then-network/sw.js | |
+++ b/cache-then-network/sw.js | |
@@ -6,15 +6,12 @@ var cacheName = 'cache-then-network'; | |
self.addEventListener('install', function(ev) { | |
console.log('SW install event'); | |
- self.skipWaiting(); | |
- ev.waitUntil(self.clients.claim()); | |
- console.log('Leaving SW install event'); | |
+ ev.waitUntil(self.skipWaiting()); | |
}); | |
self.addEventListener('activate', function(ev) { | |
- console.log('SW activate event'); | |
+ console.log('SW activate'); | |
ev.waitUntil(self.clients.claim()); | |
- console.log('Leaving SW activate event'); | |
}); | |
self.addEventListener('fetch', function(ev) { | |
@@ -29,10 +26,9 @@ self.addEventListener('fetch', function(ev) { | |
console.log('SW opened cache'); | |
cache.put(reqURL, res); | |
console.log('SW cached data'); | |
- console.log('Cache keys:'); | |
- for (var it = 0; it < cache.keys().length; it++) { | |
- console.log('\t' + cache.keys()[it]); | |
- } | |
+ cache.keys().then(function(response) { | |
+ console.log('Cache keys:', response); | |
+ }); | |
}); | |
console.log('SW returning response'); | |
return res.clone(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment