21 lines
443 B
JavaScript
21 lines
443 B
JavaScript
|
|
const CACHE_NAME = 'pozoapp-v1';
|
||
|
|
const urlsToCache = [
|
||
|
|
'/',
|
||
|
|
'/static/css/main.css',
|
||
|
|
'/static/js/main.js',
|
||
|
|
'/og/home.jpg'
|
||
|
|
];
|
||
|
|
|
||
|
|
self.addEventListener('install', event => {
|
||
|
|
event.waitUntil(
|
||
|
|
caches.open(CACHE_NAME)
|
||
|
|
.then(cache => cache.addAll(urlsToCache))
|
||
|
|
);
|
||
|
|
});
|
||
|
|
|
||
|
|
self.addEventListener('fetch', event => {
|
||
|
|
event.respondWith(
|
||
|
|
caches.match(event.request)
|
||
|
|
.then(response => response || fetch(event.request))
|
||
|
|
);
|
||
|
|
});
|