nextjs-caching
Installation
SKILL.md
Caching Architecture
Priority: P1 (HIGH)
Next.js 4 distinct caching layers. Understanding them prevents stale data bugs.
Workflow: Configure Caching for Feature
- Choose cache strategy — SSG (
force-cache), ISR (revalidate: N), or SSR (no-store). - Tag cacheable fetches — Add
next: { tags: ['posts'] }to fetch options. - Invalidate on mutation — Call
revalidateTag('posts')in Server Actions. - Deduplicate requests — Wrap shared data fetches with React
cache(). - Clear client cache — Use
router.refresh()after client-side mutations.