diff options
author | Andrew Dolgov <[email protected]> | 2017-02-26 20:10:08 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-02-26 20:10:08 +0300 |
commit | 10a40110efc6aab0387e097e15ab7bfd724942ff (patch) | |
tree | 76a93a942a6fdae600379fadda11ed7639b499fe | |
parent | b423bb5454ed6db68f1d4ff0cd27da330a753543 (diff) |
Revert "worker: only handle GET requests; update local cache with newer network files"
This reverts commit d647fdd547147596634ce712fb591119cb45bbb5.
-rw-r--r-- | worker.js | 29 |
1 files changed, 6 insertions, 23 deletions
@@ -33,12 +33,10 @@ self.addEventListener('install', function(event) { this.addEventListener('fetch', function(event) { var req = event.request.clone(); - if (req.method != "GET") return; + if (!navigator.onLine) { + event.respondWith( + caches.match(req).then(function(resp) { - event.respondWith( - caches.match(req).then(function(resp) { - - if (!navigator.onLine) { if (resp) return resp; if (req.url.match("read.html")) { @@ -48,22 +46,7 @@ this.addEventListener('fetch', function(event) { if (req.url.match("index.php")) { return caches.match("offline.html"); } - - return; - } - - //console.log("<<<", req.url); - - // refresh cached files - return caches.open(CACHE_NAME).then(function(cache) { - return fetch(req.url,{credentials: 'include'}).then(function(resp) { - return caches.match(req).then(function(match) { - if (match) cache.put(req.url, resp.clone()); - return resp; - }); - }); - }); - }) - ); - + }) + ); + } }); |