Skip to content

Instantly share code, notes, and snippets.

@digitarald
Created October 13, 2015 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitarald/950b94312240c8a279c9 to your computer and use it in GitHub Desktop.
Save digitarald/950b94312240c8a279c9 to your computer and use it in GitHub Desktop.
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