pwa: automatic update UX - no more hard refresh
- ui/version.json: server-side version marker, polled by pwa.js (load, 5 min, tab focus, network online); mismatch -> toast + auto reload once per version - pwa.js: silent reload when tab hidden, guarded reload (sessionStorage) so a partial deploy cannot loop, ATUpdate.check() exposed for testing - _shared.css: .mu-update-toast pill (bottom center, reduced-motion aware) - shell js/css get ?v=<version> automatically (bump-version.py) so HTTP cache cannot serve stale files before the service worker takes control - sw: cache fallback now ignores query string (precache still matches ?v= URLs) - bump-version.py: writes version.json + verifies it in --check - VERSION 2026.09.27.108
This commit is contained in:
1 parent
449afb923a
commit
fcdab3ac80
8 files changed
+248
-50
No files matched your search
@@ -13,7 +13,7 @@
|
||||
- ขั้นตอนอัปเดต: ดู AGENTS.md หัวข้อ PWA
|
||||
============================================================ */
|
||||
|
||||
const VERSION = "2026.09.27.107"; // ← bump ทุกครั้งที่แก้ SW เอง
|
||||
const VERSION = "2026.09.27.108"; // ← bump ทุกครั้งที่แก้ SW เอง
|
||||
const CACHE = `at-transit-${VERSION}`;
|
||||
|
||||
const PRECACHE = [
|
||||
@@ -166,7 +166,8 @@ async function networkFirst(request) {
|
||||
if (res.ok) cache.put(request, res.clone());
|
||||
return res;
|
||||
} catch {
|
||||
const hit = await cache.match(request);
|
||||
/* ?v=<version> ทำให้ URL ต่างจากตอน precache → จับคู่แบบไม่สน query */
|
||||
const hit = (await cache.match(request)) || (await cache.match(request, { ignoreSearch: true }));
|
||||
return hit || Response.error();
|
||||
}
|
||||
}
|
||||
@@ -187,7 +188,7 @@ async function networkFirstDocument(request) {
|
||||
}
|
||||
|
||||
async function cacheFirst(request) {
|
||||
const hit = await caches.match(request);
|
||||
const hit = (await caches.match(request)) || (await caches.match(request, { ignoreSearch: true }));
|
||||
if (hit) return hit;
|
||||
const cache = await caches.open(CACHE);
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user