Spaces:
Running
Running
| const CACHE_NAME = 'swiss-army-tools-v1'; | |
| const urlsToCache = [ | |
| '/', | |
| '/index.html', | |
| 'https://cdn.tailwindcss.com', | |
| 'https://unpkg.com/feather-icons', | |
| 'https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js', | |
| 'https://cdn.jsdelivr.net/npm/[email protected]/qrcode.min.js' | |
| ]; | |
| 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); | |
| } | |
| ) | |
| ); | |
| }); |