PWA: publish an app version so stale shells are detectable
The service worker version had never moved past 1.0.0 and nothing on the page said which build was loaded, so an old cached shell looked identical to a fresh one. - public/version.json: app, version, builtAt, pwa - sw.js VERSION -> 2026.10.24.1 (new cache name, old caches dropped on activate) - next.config: sw.js and version.json are served no-cache, no-store, plus Service-Worker-Allowed: / ; ui-manifest.json must-revalidate - layout: <html data-app-version> read from version.json at build time - PwaBoot: paints the version into the footer badge, polls /version.json (1.5s then every 5 min) and reloads once when it differs; guards against reload loops - footer shows v2026.10.24.1 in mono next to the copyright Verified: sw.js, /version.json and <html data-app-version> all report 2026.10.24.1, the footer badge shows it, and /stops renders the three search tabs with the near-me panel in its own tab.
This commit is contained in:
1 parent
7652ddaae5
commit
0cf391afba
8 files changed
+96
-4
No files matched your search
@@ -15,9 +15,10 @@
|
||||
- SW ใหม่ → skipWaiting + clients.claim + แจ้งหน้าเว็บ
|
||||
============================================================ */
|
||||
|
||||
const VERSION = "1.0.1"; /* bump เมื่อแก้ UI เพื่อบังคับให้ cache เก่าถูกทิ้ง */
|
||||
const VERSION = "2026.10.24.1"; /* bump เมื่อแก้ UI เพื่อบังคับให้ cache เก่าถูกทิ้ง */
|
||||
const CACHE = `atroute-${VERSION}`;
|
||||
const OFFLINE_URL = "/offline.html";
|
||||
const VERSION_URL = "/version.json";
|
||||
|
||||
/* ไฟล์ที่ precache ไว้ใช้ตอนออฟไลน์ (เฉพาะที่ path คงที่) */
|
||||
const PRECACHE = [
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"app": "Atroute",
|
||||
"version": "2026.10.24.1",
|
||||
"builtAt": "2026-10-24T00:25:14",
|
||||
"pwa": true
|
||||
}
|
||||
Reference in new issue
Block a user