Commit a51b8044 authored by Joseph's avatar Joseph Committed by Jiachi Liu

docs: cacheHandlers (#85311)

parent a63951f4
...@@ -7,6 +7,7 @@ related: ...@@ -7,6 +7,7 @@ related:
links: links:
- app/api-reference/directives/use-cache - app/api-reference/directives/use-cache
- app/api-reference/config/next-config-js/cacheComponents - app/api-reference/config/next-config-js/cacheComponents
- app/api-reference/config/next-config-js/cacheHandlers
- app/api-reference/functions/cacheLife - app/api-reference/functions/cacheLife
- app/api-reference/functions/cacheTag - app/api-reference/functions/cacheTag
- app/guides/prefetching - app/guides/prefetching
......
...@@ -8,6 +8,7 @@ related: ...@@ -8,6 +8,7 @@ related:
- app/api-reference/directives/use-cache - app/api-reference/directives/use-cache
- app/api-reference/directives/use-cache-private - app/api-reference/directives/use-cache-private
- app/api-reference/config/next-config-js/cacheComponents - app/api-reference/config/next-config-js/cacheComponents
- app/api-reference/config/next-config-js/cacheHandlers
- app/api-reference/functions/cacheLife - app/api-reference/functions/cacheLife
- app/api-reference/functions/cacheTag - app/api-reference/functions/cacheTag
- app/api-reference/functions/connection - app/api-reference/functions/connection
......
...@@ -8,6 +8,7 @@ related: ...@@ -8,6 +8,7 @@ related:
- app/api-reference/directives/use-cache-private - app/api-reference/directives/use-cache-private
- app/api-reference/config/next-config-js/cacheComponents - app/api-reference/config/next-config-js/cacheComponents
- app/api-reference/config/next-config-js/cacheLife - app/api-reference/config/next-config-js/cacheLife
- app/api-reference/config/next-config-js/cacheHandlers
- app/api-reference/functions/cacheTag - app/api-reference/functions/cacheTag
- app/api-reference/functions/cacheLife - app/api-reference/functions/cacheLife
- app/api-reference/functions/revalidateTag - app/api-reference/functions/revalidateTag
...@@ -112,7 +113,7 @@ This means `use cache` cannot be used with [runtime data](/docs/app/getting-star ...@@ -112,7 +113,7 @@ This means `use cache` cannot be used with [runtime data](/docs/app/getting-star
## `use cache` at runtime ## `use cache` at runtime
On the **server**, the cache entries of individual components or functions will be cached in-memory. On the **server**, the cache entries of individual components or functions will be cached in-memory by default. You can customize the cache storage by configuring [`cacheHandlers`](/docs/app/api-reference/config/next-config-js/cacheHandlers) in your `next.config.js` file.
Then, on the **client**, any content returned from the server cache will be stored in the browser's memory for the duration of the session or until [revalidated](#during-revalidation). Then, on the **client**, any content returned from the server cache will be stored in the browser's memory for the duration of the session or until [revalidated](#during-revalidation).
......
--- ---
title: cacheLife title: cacheLife
description: Learn how to set up cacheLife configurations in Next.js. description: Learn how to set up cacheLife configurations in Next.js.
related:
title: Related
description: View related API references.
links:
- app/api-reference/directives/use-cache
- app/api-reference/config/next-config-js/cacheHandlers
- app/api-reference/functions/cacheLife
--- ---
The `cacheLife` option allows you to define **custom cache profiles** when using the [`cacheLife`](/docs/app/api-reference/functions/cacheLife) function inside components or functions, and within the scope of the [`use cache` directive](/docs/app/api-reference/directives/use-cache). The `cacheLife` option allows you to define **custom cache profiles** when using the [`cacheLife`](/docs/app/api-reference/functions/cacheLife) function inside components or functions, and within the scope of the [`use cache` directive](/docs/app/api-reference/directives/use-cache).
......
...@@ -6,7 +6,7 @@ description: Configure the Next.js cache used for storing and revalidating data ...@@ -6,7 +6,7 @@ description: Configure the Next.js cache used for storing and revalidating data
You can configure the Next.js cache location if you want to persist cached pages and data to durable storage, or share the cache across multiple containers or instances of your Next.js application. You can configure the Next.js cache location if you want to persist cached pages and data to durable storage, or share the cache across multiple containers or instances of your Next.js application.
> **Good to know**: The `cacheHandler` configuration is specifically used by Next.js for server cache operations such as storing and revalidating ISR and route handler responses. It is not used by `'use cache'`, `'use cache: remote'`, nor `'use cache: private'`, which manage their own cache independently. > **Good to know**: The `cacheHandler` (singular) configuration is specifically used by Next.js for server cache operations such as storing and revalidating ISR and route handler responses. It is **not** used by `'use cache'` directives. For `'use cache'` directives, use [`cacheHandlers`](/docs/app/api-reference/config/next-config-js/cacheHandlers) (plural) instead.
```js filename="next.config.js" ```js filename="next.config.js"
module.exports = { module.exports = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment