Next.js 16 Cache Components guidance — PPR, use cache directive, cacheLife, cacheTag, updateTag, and migration from unstable_cache. Use when implementing partial prerendering, caching strategies, or migrating from older Next.js cache patterns.
يبقى الأمر في سطر واحد. مرّر أفقيًا لمراجعته كاملًا قبل النسخ.
تفضّل نسخة محلية؟ نزّل الملفات المتاحة حاليًا لدى SkillsMP.
مستكشف الملفات
3 ملفات
عرض SKILL.md
SKILL.md
تعليمات المصدر · معاينة للقراءة فقط
name
next-cache-components
description
Next.js 16 Cache Components guidance — PPR, use cache directive, cacheLife, cacheTag, updateTag, and migration from unstable_cache. Use when implementing partial prerendering, caching strategies, or migrating from older Next.js cache patterns.
metadata
{"priority":6,"docs":["https://nextjs.org/docs/app/getting-started/cache-components","https://nextjs.org/docs/app/api-reference/directives/use-cache"],"pathPatterns":["next.config.*","app/**","src/app/**","apps/*/app/**","apps/*/src/app/**"],"importPatterns":["next/cache"],"bashPatterns":["\\bnext\\s+(dev|build)\\b"],"promptSignals":{"phrases":["use cache","cache components","partial prerendering","PPR","cacheLife","cacheTag","updateTag","unstable_cache"],"allOf":[["cache","component"],["cache","directive"],["partial","prerender"]],"anyOf":["revalidateTag","stale","revalidate","cache profile"],"noneOf":[],"minScore":6},"validate":[{"pattern":"unstable_cache\\s*\\(","message":"unstable_cache is deprecated in Next.js 16 — use the \"use cache\" directive with cacheTag() and cacheLife() instead","severity":"recommended","upgradeToSkill":"next-cache-components","upgradeWhy":"Guides migration from unstable_cache to use cache directive with cacheTag and cacheLife."},{"pattern":"\\bcacheHandler\\s*:","message":"Singular cacheHandler is deprecated in Next.js 16 — use cacheHandlers (plural) with per-type handlers","severity":"recommended"},{"pattern":"revalidateTag\\(\\s*['\"][^'\"]+['\"]\\s*\\)","message":"Single-arg revalidateTag(tag) is deprecated in Next.js 16 — pass a cacheLife profile: revalidateTag(tag, \"max\")","severity":"recommended"}]}
retrieval
{"aliases":["cache components","partial prerendering","PPR","use cache"],"intents":["enable partial prerendering in Next.js","cache async data with use cache directive","invalidate cache with cacheTag","migrate from unstable_cache"],"entities":["use cache","cacheLife","cacheTag","updateTag","revalidateTag","PPR"]}
chainTo
[{"pattern":"use cache","targetSkill":"nextjs","message":"Cache component detected — loading Next.js best practices for RSC boundaries and data patterns alongside caching.","skipIfFileContains":"next-best-practices"}]
Cache Components (Next.js 16+)
Cache Components enable Partial Prerendering (PPR) - mix static, cached, and dynamic content in a single route.
unstable_cache has been replaced by the use cache directive in Next.js 16. When cacheComponents is enabled, convert unstable_cache calls to use cache functions:
No manual cache keys - use cache generates keys automatically from function arguments and closures. The keyParts array from unstable_cache is no longer needed.
Tags - Replace options.tags with cacheTag() calls inside the function.
Revalidation - Replace options.revalidate with cacheLife({ revalidate: N }) or a built-in profile like cacheLife('minutes').
Dynamic data - unstable_cache did not support cookies() or headers() inside the callback. The same restriction applies to use cache, but you can use 'use cache: private' if needed.
Limitations
Edge runtime not supported - requires Node.js
Static export not supported - needs server
Non-deterministic values (Math.random(), Date.now()) execute once at build time inside use cache
For request-time randomness outside cache:
import { connection } from'next/server'asyncfunctionDynamicContent() {
awaitconnection() // Defer to request timeconst id = crypto.randomUUID() // Different per requestreturn<div>{id}</div>
}