const CACHE_NAME = 'timetracker-v1'; // Add the paths to the files you want to cache const urlsToCache = [ '/', '/index.html' // If you had separate CSS or JS files, you would add them here too. // e.g., '/style.css', '/app.js' ]; // Install the service worker and cache the app shell self.addEventListener('install', event => { event.waitUntil( caches.open(CACHE_NAME) .then(cache => { console.log('Opened cache'); return cache.addAll(urlsToCache); }) ); }); // Intercept network requests and serve from cache if available self.addEventListener('fetch', event => { event.respondWith( caches.match(event.request) .then(response => { // Cache hit - return response if (response) { return response; } // Not in cache - fetch from network return fetch(event.request); }) ); });