From ec1db3fc34761b0bcfe8e8fcac80494713889efc Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 3 Mar 2018 21:41:26 -0500 Subject: [PATCH] fix and update service worker --- app/service-worker.js | 5 ++++- app/template.html | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/service-worker.js b/app/service-worker.js index 542371d..e7f27f4 100644 --- a/app/service-worker.js +++ b/app/service-worker.js @@ -37,8 +37,11 @@ self.addEventListener('fetch', event => { // don't try to handle e.g. data: URIs if (!url.protocol.startsWith('http')) return; + // ignore dev server requests + if (url.hostname === self.location.hostname && url.port !== self.location.port) return; + // always serve assets and webpack-generated files from cache - if (cached.has(url.pathname)) { + if (url.host === self.location.host && cached.has(url.pathname)) { event.respondWith(caches.match(event.request)); return; } diff --git a/app/template.html b/app/template.html index a7e7d49..5dc665a 100644 --- a/app/template.html +++ b/app/template.html @@ -10,9 +10,9 @@