fix: cache auto renewal

This commit is contained in:
2026-08-05 18:55:14 +03:00
parent 401157994f
commit 7567e1b726
2 changed files with 21 additions and 9 deletions
+1
View File
@@ -925,6 +925,7 @@ function updateRamFields() {
document.getElementById('ram-enc-row').style.display = cmd === 'store-data' ? '' : 'none';
document.getElementById('ram-del-mode-row').style.display = cmd === 'delete' ? '' : 'none';
document.getElementById('ram-gs-mode-row').style.display = cmd === 'get-status' ? '' : 'none';
document.getElementById('ram-gs-p2-row').style.display = cmd === 'get-status' ? '' : 'none';
document.getElementById('ram-tag-row').style.display = cmd === 'get-data' ? '' : 'none';
document.getElementById('ram-ss-mode-row').style.display = cmd === 'set-status' ? '' : 'none';
document.getElementById('ram-ss-state-row').style.display = cmd === 'set-status' ? '' : 'none';
+20 -9
View File
@@ -1,4 +1,4 @@
const CACHE = 'otaman-v1';
const CACHE = 'otaman-v2';
const URLS = [
'index.html',
'style.css',
@@ -20,16 +20,27 @@ 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 => {
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;
}))
);
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;
}))
);
}
});