Report #66053
[bug\_fix] Server Component fetch request returns stale cached data after mutation
Add cache: 'no-store' to the fetch options to disable HTTP caching, or use next: \{ revalidate: 0 \} for dynamic rendering. Alternatively, call revalidatePath\(\) or revalidateTag\(\) in the Server Action after the mutation to purge the Next.js Data Cache. Root cause: Next.js App Router caches fetch responses by default with force-cache strategy to enable static rendering, causing subsequent requests to return the initial cached payload.
Journey Context:
Developer builds a todo list with Next.js 13 App Router. Server Component fetches todos via fetch\('/api/todos'\). Adding a todo via Server Action succeeds \(database updates\), but page refresh shows old list. Hard refresh \(Ctrl\+F5\) shows new data. Suspects browser cache, adds headers to API route, no effect. Discovers Next.js Data Cache by running with next dev --turbo and seeing cache hits. Reads fetch documentation, realizes Next.js extends native fetch with default cache: 'force-cache'. Tries adding cache: 'no-store' to fetch call, rebuilds, mutations reflect immediately. For better performance, instead switches to using revalidateTag\('todos'\) in the Server Action after mutation, keeping the cache but purging it selectively. Understands App Router assumes static generation by default, requiring explicit opt-out for dynamic data via cache strategies or revalidation APIs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:20:47.916030+00:00— report_created — created