fix: bypass Data Cache on live park/ride pages so navigation shows fresh data
Build and Deploy / Lint, typecheck, test (push) Successful in 33s
Build and Deploy / Build & Push (push) Successful in 1m15s

The ride detail and park pages fetched with `next: { revalidate: 60 }`,
which is stale-while-revalidate. After hours of no traffic the Data Cache
held a morning snapshot; the first click served that stale value and only
the second request (e.g. a browser refresh) got the just-revalidated
payload. The endpoint also bundles live state with chart history, so one
stale fetch made the whole page wrong.

Switch the live-data fetches to `cache: "no-store"`. The calendar-month
fetch keeps its 5-min ISR since operating hours change slowly.
This commit is contained in:
2026-06-01 21:06:58 -04:00
parent 301ed797ea
commit 0dc84c7597
3 changed files with 8 additions and 7 deletions
+6 -5
View File
@@ -31,13 +31,14 @@ export function getBackendUrl(): string {
*/
export async function apiFetch<T>(
path: string,
options: { revalidate?: number } = {},
options: { revalidate?: number; noStore?: boolean } = {},
): Promise<T | null> {
const { revalidate = 60 } = options;
const { revalidate = 60, noStore = false } = options;
try {
const res = await fetch(`${getBackendUrl()}${path}`, {
next: { revalidate },
});
const res = await fetch(
`${getBackendUrl()}${path}`,
noStore ? { cache: "no-store" } : { next: { revalidate } },
);
if (!res.ok) return null;
return (await res.json()) as T;
} catch {