From 10a40110efc6aab0387e097e15ab7bfd724942ff Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 26 Feb 2017 20:10:08 +0300 Subject: Revert "worker: only handle GET requests; update local cache with newer network files" This reverts commit d647fdd547147596634ce712fb591119cb45bbb5. --- worker.js | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/worker.js b/worker.js index 88a97c4..219947f 100644 --- a/worker.js +++ b/worker.js @@ -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; - }); - }); - }); - }) - ); - + }) + ); + } }); -- cgit v1.2.3