summaryrefslogtreecommitdiff
path: root/worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'worker.js')
-rw-r--r--worker.js29
1 files 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;
- });
- });
- });
- })
- );
-
+ })
+ );
+ }
});