mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-17 20:34:53 +00:00
fix and update service worker
This commit is contained in:
@@ -37,8 +37,11 @@ self.addEventListener('fetch', event => {
|
|||||||
// don't try to handle e.g. data: URIs
|
// don't try to handle e.g. data: URIs
|
||||||
if (!url.protocol.startsWith('http')) return;
|
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
|
// 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));
|
event.respondWith(caches.match(event.request));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
<link rel='icon' type='image/png' href='/favicon.png'>
|
<link rel='icon' type='image/png' href='/favicon.png'>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
// navigator.serviceWorker.register('/service-worker.js');
|
navigator.serviceWorker.register('/service-worker.js');
|
||||||
// }
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Sapper generates a <style> tag containing critical CSS
|
<!-- Sapper generates a <style> tag containing critical CSS
|
||||||
|
|||||||
Reference in New Issue
Block a user