diff options
Diffstat (limited to 'worker.js')
-rw-r--r-- | worker.js | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -30,6 +30,26 @@ self.addEventListener('install', function(event) { ); }); +self.addEventListener('message', function(event){ + if (event.data == 'refresh-cache') { + console.log("refreshing cache..."); + + caches.open(CACHE_NAME).then(function(cache) { + cache.keys().then(function(keys) { + for (var i = 0; i < keys.length; i++) { + + fetch(keys[i],{credentials:'same-origin'}).then(function(resp) { + if (resp.status == 200) { + cache.put(resp.url, resp); + } + }); + + } + }); + }); + } +}); + this.addEventListener('fetch', function(event) { var req = event.request.clone(); |