From 64d28f0b1f2caccf374be9c75d85017063fb358b Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Mon, 13 Jun 2016 13:32:49 +0100 Subject: [PATCH] Attempt to fix page load issues on staging server --- public/service-worker.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/public/service-worker.js b/public/service-worker.js index 2d3a8f0f..a0f174cf 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -56,15 +56,19 @@ self.addEventListener('activate', function (event) { // Basic offline mode // Just respond with an offline error page for now self.addEventListener('fetch', function(event) { - event.respondWith( - caches.match(event.request).then(function(response) { - return response || fetch(event.request); - }).catch(function () { - if (event.request.mode == 'navigate') { - return caches.match('/offline.html'); - } - }) - ) + if (event.request.url.indexOf('stage.pony.fm') > -1) { + event.respondWith(fetch(event.request)); + } else { + event.respondWith( + caches.match(event.request).then(function (response) { + return response || fetch(event.request); + }).catch(function () { + if (event.request.mode == 'navigate') { + return caches.match('/offline.html'); + } + }) + ) + } }); self.addEventListener('push', function(event) {