Files
otaman/frontend/sw.js
T
catarrh 0ecfd5f720 profiler: compact rule editor layout
- Path field narrowed to w-72 with the FCP/FCI selector to its right in
  one row
- File type + size (or record length + count) now sit in a single flex
  row (fixes the accidental wrap from the unavailable md:grid-cols-4 class
  in the prebuilt CSS)
- 'Contents' label renamed to 'Check contents' and the None/Exact/Mask
  radios moved inline to its right, saving one line per rule

Rendering-only change; no logic or test behavior affected. SW cache v54 -> v55.
2026-09-10 22:31:25 +03:00

56 lines
1.4 KiB
JavaScript

const CACHE = 'otaman-v55';
const URLS = [
'index.html',
'help.html',
'help-ru.html',
'style.css',
'sim.png',
'favicon.svg',
'icon-192.png',
'icon-512.png',
'manifest.json',
'des-bundle.js',
'aes-bundle.js',
'sim.svg',
'sim_anim.svg',
'nosim.svg',
];
self.addEventListener('install', e => {
e.waitUntil(
caches.open(CACHE).then(c => c.addAll(URLS))
);
self.skipWaiting();
});
self.addEventListener('activate', e => {
e.waitUntil(
caches.keys().then(keys =>
Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))
).then(() => clients.claim())
);
});
self.addEventListener('fetch', e => {
if (!e.request.url.startsWith('http')) return;
if (new URL(e.request.url).pathname.startsWith('/api/')) return; // live data, never cache
if (e.request.method !== 'GET') return;
const isNavigate = e.request.mode === 'navigate' || e.request.url.endsWith('sw.js');
if (isNavigate) {
e.respondWith(
fetch(e.request).then(res => {
const clone = res.clone();
caches.open(CACHE).then(c => c.put(e.request, clone));
return res;
}).catch(() => caches.match(e.request))
);
} else {
e.respondWith(
caches.match(e.request).then(r => r || fetch(e.request).then(res => {
const clone = res.clone();
caches.open(CACHE).then(c => c.put(e.request, clone));
return res;
}))
);
}
});