Files
Tiber365/public/sw.js
2025-07-24 18:46:24 +02:00

55 lines
1.1 KiB
JavaScript

const CACHE_NAME = 'tiber365-v1';
const urlsToCache = [
'/',
'/en/',
'/nl/',
'/de/',
'/fr/',
'/en/about',
'/nl/about',
'/de/about',
'/fr/about',
'/en/contact',
'/nl/contact',
'/de/contact',
'/fr/contact',
'/services',
'/blog',
'/favicon.svg',
'/manifest.json',
'/images/TIBER365.png'
];
// Install event
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME)
.then((cache) => cache.addAll(urlsToCache))
);
});
// Fetch event
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request)
.then((response) => {
// Return cached version or fetch from network
return response || fetch(event.request);
})
);
});
// Activate event
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheName !== CACHE_NAME) {
return caches.delete(cacheName);
}
})
);
})
);
});