Last active
October 25, 2017 19:45
-
-
Save evemilano/1412d768a6974bf570712bccb01ffa66 to your computer and use it in GitHub Desktop.
Service Worker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* EVE Milano sw.js | |
* Copyright 2017 Giovanni Sacheli All rights reserved. | |
* Version 1.2 (20 settembre 2017) | |
*/ | |
self.addEventListener('install', e => { | |
console.log('PWA Service Worker installing.'); | |
let timeStamp = Date.now(); | |
e.waitUntil( | |
caches.open('evemilano_service_worker').then(cache => { | |
return cache.addAll([ | |
'/wp-content/themes/metro-pro/style.css', | |
'/', | |
'/?utm_source=homescreen', | |
'/wp-content/uploads/2015/07/logo-blu-270x80-da-vettoriale.png', | |
'/wp-content/plugins/eve_social_buttons/images/socicon.eot', | |
'/wp-content/plugins/eve_social_buttons/images/socicon.woff', | |
'/wp-content/plugins/eve_social_buttons/images/socicon.ttf', | |
'/wp-content/plugins/eve_social_buttons/images/socicon.svg' | |
]) | |
.then(() => self.skipWaiting()); | |
}) | |
) | |
}); | |
self.addEventListener('activate', event => { | |
console.log('PWA Service Worker activating.'); | |
event.waitUntil(self.clients.claim()); | |
}); | |
self.addEventListener('fetch', event => { | |
event.respondWith( | |
caches.match(event.request).then(response => { | |
return response || fetch(event.request); | |
}) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Guida: https://www.evemilano.com/2017/10/progressive-web-app/