const CACHE_NAME = 'eur-dzd-calculator-v1'; const urlsToCache = [ '/', '/index.html', '/icon.png', '/manifest.json', // Add more URLs of assets to cache here ]; self.addEventListener('install', event => { event.waitUntil( caches.open(CACHE_NAME) .then(cache => cache.addAll(urlsToCache)) .catch(error => console.error('Error caching assets:', error)) ); }); self.addEventListener('fetch', event => { event.respondWith( caches.match(event.request) .then(response => { if (response) { return response; // Serve cached asset if available } return fetch(event.request); // Otherwise, fetch from network }) .catch(error => console.error('Error fetching asset:', error)) ); });