32 lines
678 B
JavaScript
Executable File
32 lines
678 B
JavaScript
Executable File
const CACHE_NAME = 'domili-cache-v1';
|
|
const urlsToCache = [
|
|
'/',
|
|
'/index.php',
|
|
'/css/style.css',
|
|
'inc/header.php',
|
|
'inc/footer.php',
|
|
'img/icon-192.png',
|
|
'img/icon-512.png',
|
|
'https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css'
|
|
];
|
|
|
|
self.addEventListener('install', event => {
|
|
event.waitUntil(
|
|
caches.open(CACHE_NAME)
|
|
.then(cache => {
|
|
return cache.addAll(urlsToCache);
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener('fetch', event => {
|
|
event.respondWith(
|
|
caches.match(event.request)
|
|
.then(response => {
|
|
if (response) {
|
|
return response;
|
|
}
|
|
return fetch(event.request);
|
|
})
|
|
);
|
|
}); |