caching-strategy

Configure Next.js Cache Components with cacheLife and cacheTag for revalidation.

1.5k|875|Updated Aug 20, 2021
One-click install
npx skills add https://github.com/saleor/storefront --skill caching-strategy-saleor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: caching-strategy
Source: https://github.com/saleor/storefront/tree/main/.claude/skills/caching-strategy
Command: npx skills add https://github.com/saleor/storefront --skill caching-strategy-saleor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Understand the caching architecture, Cache Components (PPR), and revalidation mechanisms. Use when debugging stale content, modifying caching behavior, or understanding data freshness guarantees.

Core Features & Use Cases

  • Cache Components enable Partial Prerendering (PPR) to mix static, cached, and dynamic content with Suspense boundaries.
  • Tag-based invalidation via webhooks and manual revalidation for instant freshness control.
  • Public vs Authenticated queries and safe caching practices to avoid cookie leakage.

Quick Start

Enable cache components in next.config.js and annotate your data-fetching functions with use cache, cacheLife, and cacheTag to enable deterministic, cacheable rendering.

Frequently Asked Questions about caching-strategy

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

FAQPage Schema
How do I configure Next.js cache components to fix stale content?

To fix stale content with Next.js cache components, enable the feature in next.config.js and annotate data-fetching functions with use cache, cacheLife, and cacheTag to control rendering and data freshness.

How does Partial Prerendering work with Suspense boundaries in Next.js?

Partial Prerendering uses Suspense boundaries to mix static cached content with dynamic data, allowing Next.js to serve prerendered HTML shells while streaming personalized or real-time components asynchronously.

How do I use webhooks for cache invalidation in Next.js?

You can trigger immediate cache invalidation via webhooks by assigning a cacheTag to your data-fetching functions and configuring a revalidation endpoint to call Next.js manual revalidation APIs for instant freshness.

Can I cache authenticated user data safely without cookie leakage?

You can safely cache public data using Next.js cache components, but you must isolate authenticated queries and avoid caching personalized responses to prevent cookie leakage and ensure safe data practices.

What is the best way to manage data freshness across dynamic Next.js pages?

The best way to manage data freshness across Next.js pages is defining cacheLife durations and utilizing tag-based invalidation, ensuring deterministic updates across categories and dynamic components without full rebuilds.