Serve HTML with no-store so a plain reload picks up a new deploy

Root cause of 'the change never appears': pages are statically prerendered,
so Next replied with Cache-Control: s-maxage=31536000. The browser kept the
old HTML for up to a year, which is why editing sw.js and the footer version
changed nothing for an existing visitor.

next.config now adds, for any request whose Accept includes text/html:
  Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
Static assets are untouched (hashed files under _next/static keep their
immutable caching).

Bumped version.json and the SW VERSION to 2026.10.24.2.

Verified with curl (Accept: text/html) that /, /stops, /routes, /about and
/credits all return no-store, while images still return public, max-age=0;
and in the browser an ordinary reload returns the three-tab /stops page with
the v2026.10.24.2 footer badge.
This commit is contained in:
Bkk1234 committed 2026-10-24 00:34:51 +07:00
1 parent 0cf391afba
commit 18f7a6e34b
3 files changed
+13 -3

No files matched your search

+10
View File
@@ -26,6 +26,16 @@ const nextConfig = {
source: "/ui-manifest.json",
headers: [{ key: "Cache-Control", value: "public, max-age=0, must-revalidate" }],
},
{
/* หน้าเว็บ (HTML) เป็น static prerender → Next แปะ s-maxage=31536000 (1 ปี)
ทำให้เบราว์เซอร์ค้างหน้าเก่าหลัง deploy ใหม่ จึงบังคับ no-store เฉพาะ text/html
(ไม่กระทบ _next/static ที่มี hash อยู่แล้ว) */
source: "/:path*",
has: [{ type: "header", key: "accept", value: "(.*text/html.*)" }],
headers: [
{ key: "Cache-Control", value: "private, no-cache, no-store, max-age=0, must-revalidate" },
],
},
];
},
async rewrites() {
+1 -1
View File
@@ -15,7 +15,7 @@
- SW ใหม่ → skipWaiting + clients.claim + แจ้งหน้าเว็บ
============================================================ */
const VERSION = "2026.10.24.1"; /* bump เมื่อแก้ UI เพื่อบังคับให้ cache เก่าถูกทิ้ง */
const VERSION = "2026.10.24.2"; /* bump เมื่อแก้ UI เพื่อบังคับให้ cache เก่าถูกทิ้ง */
const CACHE = `atroute-${VERSION}`;
const OFFLINE_URL = "/offline.html";
const VERSION_URL = "/version.json";
+2 -2
View File
@@ -1,6 +1,6 @@
{
"app": "Atroute",
"version": "2026.10.24.1",
"builtAt": "2026-10-24T00:25:14",
"version": "2026.10.24.2",
"builtAt": "2026-10-24T00:33:20",
"pwa": true
}