cache-components

Implement Next.js Cache Components with 'use cache', cacheLife, and cacheTag.

1|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/AngelP17/factoryops-console --skill cache-components-angelp17
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cache-components
Source: https://github.com/AngelP17/factoryops-console/tree/main/factoryops-console/.agent/skills/cache-components
Command: npx skills add https://github.com/AngelP17/factoryops-console --skill cache-components-angelp17

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires .

What problem does it solve?

This Skill provides expert guidance for implementing Next.js Cache Components and Partial Prerendering (PPR). It auto-activates in projects that set cacheComponents: true in next.config, helping teams co-locate caching decisions with components and achieve a static shell plus dynamic streaming experience.

Core Features & Use Cases

  • Proactive activation when cacheComponents is detected in next.config.ts/next.config.js, ensuring patterns are applied across React Server Components, data fetching, and Server Actions.
  • Guidance on using the 'use cache' directive, cacheLife, cacheTag, updateTag, revalidateTag, and revalidatePath for precise invalidation, shared caches, and SWR-style background refresh.
  • Strategies for building pages with static shells, cached components, and Suspense-wrapped dynamic sections, including generateStaticParams subshells and multi-level caching.
  • Built-in guidance for debugging, performance tuning, and avoiding common anti-patterns to maximize cache effectiveness.

Quick Start

Enable Cache Components in next.config by setting cacheComponents: true, wrap data fetching with 'use cache' and corresponding cache APIs, tag caches with cacheTag, invalidate with updateTag or revalidateTag, and compose pages with a static shell plus cached blocks and Suspense for dynamic content.

Frequently Asked Questions about cache-components

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enable caching for Next.js components with Partial Prerendering?▼

Enable Partial Prerendering by setting cacheComponents: true in next.config.ts, then use the 'use cache' directive in Server Components to wrap data-fetching logic. Tag cached sections with cacheTag and invalidate using updateTag or revalidateTag to achieve static shells with dynamic streaming content.

What's the best way to invalidate Next.js cached components?▼

Invalidate cached components using updateTag or revalidateTag to trigger background refresh, or revalidatePath for path-based invalidation. Use cacheTag to group related cached sections so invalidation affects only the intended blocks, avoiding unnecessary recomputation across your entire page.

How do I structure a page with static shells and cached components using Suspense?▼

Build pages by combining a static shell (prerendered at build time), cached component blocks tagged with cacheTag and wrapped in 'use cache', and Suspense-wrapped dynamic sections. This architecture streams dynamic content to users while serving the cached portions immediately from the static shell.

Can I use cacheLife and cacheTag together in Next.js Server Components?▼

Yes, cacheLife defines cache duration for a component or data fetch, while cacheTag labels cached sections for grouped invalidation. Use both together to set retention policies and enable precise, tag-based revalidation without purging unrelated cached blocks.

What should I avoid when implementing Next.js Cache Components?▼

Avoid placing 'use cache' around Client Components, co-locating cache logic separately from components, or invalidating entire pages when partial tags suffice. Also prevent over-caching dynamic content and neglecting Suspense boundaries, which reduce streaming benefits and defeat Partial Prerendering's performance gains.

Does Next.js Cache Components work with Server Actions?▼

Yes, Cache Components guidance covers Server Actions alongside React Server Components and data fetching. Apply 'use cache', cacheLife, and cacheTag patterns to Server Actions to control mutation-triggered invalidations and maintain consistent cache behavior across your application.