{"success":true,"name":"use-next-js-revalidation-instead-of-forcing-dynamic","description":"Next.js data feels stale and forcing dynamic rendering seems like the fix","category":"ai-brimind","path":"ai-brimind/use-next-js-revalidation-instead-of-forcing-dynamic/SKILL.md","file":"SKILL.md","content":"---\nname: use-next-js-revalidation-instead-of-forcing-dynamic\ndescription: \"Next.js data feels stale and forcing dynamic rendering seems like the fix\"\n---\n\n# Use Next.js Revalidation Instead of Forcing Dynamic\n\n## When to use\nProject is Next.js, and you are about to add force-dynamic, no-store, or client refetching because a page shows old data.\n\n## Example request\nPage shows yesterday's prices, so you reach for force-dynamic → time-based revalidate (e.g. every 60s) keeps it fast AND fresh. Admin edits content but the site doesn't update → revalidatePath or revalidateTag after the save is the built-in push mechanism. Adding a useEffect refetch to bypass the cache → the cache isn't the enemy; it just needs an expiry or a tag. Setting no-store on every fetch 'to be safe' → that silently makes the whole route dynamic and slow.\n\n## Instructions\nIf condition: a Next.js page shows stale data and you are about to force dynamic rendering or bypass caching → THEN: act as an engineer who treats stale data as a cache-configuration problem, not a caching problem. First state the hypothesis: which cache is holding the old data (fetch data cache, full route cache, or router cache) and why. Then pick the built-in tool that matches: time-based freshness → revalidate with a number of seconds; event-based freshness (data changed because someone saved something) → revalidatePath or revalidateTag triggered by that save; truly per-request data → only then dynamic rendering, and only for that fetch or route. Distinguish the surface fix (force-dynamic makes stale data disappear) from the root cause (the cache was never told when to expire), because forcing dynamic trades one bug for permanent slowness and server cost. Check what Next.js already provides before writing manual refetch code — revalidation IS the framework's answer to staleness. If you are not sure which cache layer is serving the old data, investigate or ask instead of stacking cache-busting flags. Only apply the change once the stale layer is confirmed, and explain why this uses the framework's revalidation machinery instead of disabling caching everywhere.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #479\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}