Files
numnum/sw.js
T
Трошин Антон Валерьевич 818d4a3857 png icon to fix small icon issue on android
2026-07-12 22:10:45 +03:00

35 lines
689 B
JavaScript

const CACHE_NAME = 'numnum-v14';
const ASSETS = [
'/',
'/index.html',
'/styles.css',
'/app.js',
'/numerals.js',
'/manifest.json',
'/icon.svg',
'/icon-192.png',
'/icon-512.png',
];
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS))
);
self.skipWaiting();
});
self.addEventListener('activate', (e) => {
e.waitUntil(
caches.keys().then(keys =>
Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k)))
)
);
self.clients.claim();
});
self.addEventListener('fetch', (e) => {
e.respondWith(
caches.match(e.request).then(r => r || fetch(e.request))
);
});