skills/nextjs/nextjs-caching/SKILL.md
Configure the 4 caching layers in Next.js: request memoization, data cache, full-route cache, and router cache. Use when setting revalidation strategies, invalidating cached data with tags, or diagnosing stale data bugs.
npx skillsauth add hoangnguyen0403/agent-skills-standard nextjs-cachingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Next.js 4 distinct caching layers. Understanding them prevents stale data bugs.
force-cache), ISR (revalidate: N), or SSR (no-store).next: { tags: ['posts'] } to fetch options.revalidateTag('posts') in Server Actions.cache().router.refresh() after client-side mutations.See implementation examples
fetch with revalidate: number or cache: 'force-cache' for API calls. Use unstable_cache or new 'use cache' (experimental) for custom data stores.cache() from React to deduplicate fetches within single render.revalidatePath('/') after mutations or revalidateTag('tag-name') for granular cache purging.router.refresh().generateStaticParams for pre-rendering static routes at build time. Use ISR (Incremental Static Regeneration) for content that updates periodically.Suspense with fetch triggers to prevent slow data from blocking entire page render.'use cache' and cacheLife() over revalidate: number where available for deterministic caching.| Layer | Where | Control |
| :---------------------- | :----- | :----------------------------- |
| Request Memoization | Server | React cache() |
| Data Cache | Server | 'use cache', revalidateTag |
| Full Route Cache | Server | Static Prerendering |
| Router Cache | Client | router.refresh() |
See Cache Components & PPR for detailed key generation, closure constraints, and invalidation strategies.
unstable_cache in Next.js 16+: Use 'use cache' directive with cacheLife() instead.router.refresh() for server data: Prefer revalidateTag() for targeted cache busting.<Suspense> with 'use cache'.cacheTag() for fine-grained invalidation control.development
Standardize SRS and FRS specifications for technical behavior, interfaces, data contracts, quality constraints, and verification mapping. Use when writing SRS, functional specification, system behavior requirements, API/data contracts, or non-functional thresholds.
development
Standardize BRD and BRD-lite discovery for business goals, stakeholder impact, current-to-future state, and measurable value outcomes. Use when creating BRD, business case, project justification, ROI narrative, or AS-IS to TO-BE scope.
development
Implements a strict Red-Green-Refactor loop to ensure zero production code is written without a prior failing test. Use when: creating new features, fixing bugs, or expanding test coverage.
testing
Standardize PRD discovery and drafting for product scope, user outcomes, requirement IDs, and acceptance criteria. Use when creating PRD, product requirements, feature specification, or acceptance criteria plan.