From 0dc84c75970be031f431d6450eb98cdf050e33f5 Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 1 Jun 2026 21:06:58 -0400 Subject: [PATCH] fix: bypass Data Cache on live park/ride pages so navigation shows fresh data 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. --- app/park/[id]/page.tsx | 2 +- app/park/[id]/ride/[slug]/page.tsx | 2 +- lib/api.ts | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/park/[id]/page.tsx b/app/park/[id]/page.tsx index 84d11a6..92d768a 100644 --- a/app/park/[id]/page.tsx +++ b/app/park/[id]/page.tsx @@ -73,7 +73,7 @@ export default async function ParkPage({ params, searchParams }: PageProps) { ), apiFetch( `/api/parks/${id}/rides`, - { revalidate: 60 }, + { noStore: true }, ), ]); diff --git a/app/park/[id]/ride/[slug]/page.tsx b/app/park/[id]/ride/[slug]/page.tsx index ccb9b32..2c6fcf6 100644 --- a/app/park/[id]/ride/[slug]/page.tsx +++ b/app/park/[id]/ride/[slug]/page.tsx @@ -88,7 +88,7 @@ export default async function RideDetailPage({ params, searchParams }: PageProps let res: Response; try { res = await fetch(`${getBackendUrl()}/api/parks/${id}/rides/${slug}`, { - next: { revalidate: 60 }, + cache: "no-store", }); } catch { return ; diff --git a/lib/api.ts b/lib/api.ts index 488c20b..3b09cac 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -31,13 +31,14 @@ export function getBackendUrl(): string { */ export async function apiFetch( path: string, - options: { revalidate?: number } = {}, + options: { revalidate?: number; noStore?: boolean } = {}, ): Promise { - 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 {