PWA Integration

This commit is contained in:
Borgal
2025-08-13 14:28:09 +02:00
parent f496d25917
commit 8d6233be43
5 changed files with 68 additions and 0 deletions

32
service-worker.js Executable file
View File

@@ -0,0 +1,32 @@
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);
})
);
});