1
0
forked from orson/bachemap
bachemap/static/service-worker.js

43 lines
1000 B
JavaScript

const CACHE_NAME = 'bachemapa-pwa-v2';
const urlsToCache = [
'/',
'/quienes',
'/dashboard',
'/leaderboard',
'/thelogin',
'/static/css/main.css',
'/static/js/main.js',
'/static/js/leaflet.js',
'/static/css/styles.css',
'/static/images/marker-icon.png',
'/static/images/marker-shadow.png',
'/static/images/leaflet.css',
'/static/images/contract.png',
'/static/images/contract2.png',
'/static/manifest.json',
'/manifest.json',
'/static/service-worker.js'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request)
.then(response => {
// Return cached asset if available, otherwise fetch from network
return response || fetch(event.request);
})
);
});