Next.js ~Chache~

In Next.js, there are four layers of caching strategy for performance optimization or cutting costs.
| Cache Type | Storage Location | Stored Content | Purpose | Lifetime |
|---|---|---|---|---|
| Request Memoization | Server | fetch response values |
Avoid duplicate requests within a render pass | Per request only |
| Data Cache | Server | Data | Reuse data across users and deployments | Persistent (revalidatable) |
| Full Route Cache | Server | HTML / RSC payload | Reduce rendering cost | Persistent (revalidatable) |
| Router Cache | Client | RSC payload | Reduce requests during client-side navigation | Session-based / time-limited |
Next.js 15 introduced use cache directive.
・This is a new mechanism that allows you to declare “cache this output” on a per-function or per-component basis.
・You can intuitively specify the scope of caching without using complex APIs such as the traditional unstable_cache.
・Next.js 16 introduced PPR(Partial Pre Rendering), which enhances the mechanism for delivering content quickly by combining cached static content with dynamic content.
Cache Refresh (Revalidation) There are two main ways to refresh cached data.
Time-based Revalidation: Specify the number of seconds using the next: { revalidate: 60 } option in the fetch request.
On-demand Revalidation: Use revalidatePath or revalidateTag to explicitly invalidate the cache when a data mutation occurs.





