use cache: private when you need to cache user-specific data that depends on cookies, headers, or search params.use cache, private caches can access request-specific APIs like cookies() and headers() directly inside the cached function.use cache: private, personalized content cannot be prefetched and must wait until navigation occurs.async function getRecommendations(productId: string) {
// !mark
'use cache: private';
cacheTag(`recommendations-${productId}`);
cacheLife({ stale: 60 });
// Can call cookies() INSIDE the cached function!
// !mark
const sessionId = (await cookies()).get('session-id')?.value || 'guest';
return getPersonalizedRecommendations(productId, sessionId);
}
async function Recommendations({ productId }: { productId: string }) {
// This will be runtime prefetched automatically
const recommendations = await getRecommendations(productId);
return (
<div>
{recommendations.map((rec) => (
<ProductCard key={rec.id} product={rec} />
))}
</div>
);
}
export const unstable_prefetch = {
mode: 'runtime',
samples: [
{ params: { id: '1' }, cookies: [{ name: 'session-id', value: '1' }] },
],
};
use cache: private to enable runtime prefetching. The content is still dynamic, but it's prefetched
when the static content of the page is also prefetched.use cache: private, meaning their recommendations will be loaded after navigation.use cache directive and describes caching behavior once stable.use cache: private enables runtime prefetching of dynamic content by allowing cookies() and headers() inside cached functions.unstable_prefetch export with mode: 'runtime' and cacheLife({ stale: 60 }) (≥30s).


