PWA Integration
This commit is contained in:
32
service-worker.js
Executable file
32
service-worker.js
Executable 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);
|
||||
})
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user