25 lines
504 B
JavaScript
25 lines
504 B
JavaScript
|
|
const CACHE_NAME = 'french-vocab-v1';
|
||
|
|
const urlsToCache = [
|
||
|
|
'/',
|
||
|
|
'/index.html',
|
||
|
|
'/assets/index.css',
|
||
|
|
'/assets/index.js'
|
||
|
|
];
|
||
|
|
|
||
|
|
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) => {
|
||
|
|
if (response) return response;
|
||
|
|
return fetch(event.request);
|
||
|
|
})
|
||
|
|
);
|
||
|
|
});
|