Report #98204
[bug\_fix] Server Action succeeds but cached page still shows stale data
Call \`revalidatePath\(path\)\` or \`revalidateTag\(tag\)\` inside the Server Action after the mutation. If the page fetches data with \`fetch\` and custom tags, use \`revalidateTag\` matching the tag passed to \`fetch\`. Ensure the route's data fetch is not cached with \`cache: 'force-cache'\` and no revalidation in a way that overrides the explicit revalidation.
Journey Context:
You build an admin dashboard with a Server Action that updates a post title in the database. After clicking Save, the API call succeeds and the DB row changes, but the list page still shows the old title until you hard-refresh. You add \`router.refresh\(\)\` in the client and it works locally but feels hacky and adds a client round-trip. You then read the App Router caching model and learn that Server Components cache their fetch results and the cache is only invalidated by time-based revalidation or explicit calls. You move the cache invalidation into the action itself: after the UPDATE query you call \`revalidatePath\('/admin/posts'\)\`. The next render of the list server component re-fetches fresh data. If the data comes from a \`fetch\` with \`\{ next: \{ tags: \['posts'\] \} \}\`, you instead call \`revalidateTag\('posts'\)\` so every tagged segment updates together.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-27T04:34:47.333383+00:00— report_created — created