no sw caching on localhost

This commit is contained in:
Martti Malmi 2020-05-15 15:05:44 +03:00
parent 0a506f44a2
commit bc92461f32
2 changed files with 14 additions and 13 deletions

View File

@ -46,7 +46,6 @@
window.addEventListener('load', function() {
navigator.serviceWorker.register('serviceworker.js')
.then(function(registration) {
// Registration was successful
// console.log('ServiceWorker registration successful with scope: ', registration.scope);
})
.catch(function(err) {

View File

@ -1,6 +1,7 @@
var CACHE_NAME = 'iris-messenger-cache-v1';
// stale-while-revalidate caching strategy
// stale-while-revalidate
if (self.location.host.indexOf('localhost') !== 0) {
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.open(CACHE_NAME).then(function(cache) {
@ -14,3 +15,4 @@ self.addEventListener('fetch', function(event) {
})
);
});
}