Unverified Commit 3f8febe2 authored by Wyatt Johnson's avatar Wyatt Johnson Committed by GitHub

docs: Added documentation for `"use cache: private"` (#85038)

Added documentation for `use cache: private`.

---------
Co-authored-by: 's avatarJoseph Chamochumbi <joseph.chamochumbi@vercel.com>
parent 5c34f87b
...@@ -6,6 +6,7 @@ related: ...@@ -6,6 +6,7 @@ related:
title: Related title: Related
description: View related API references. description: View related API references.
links: links:
- 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/functions/cacheTag - app/api-reference/functions/cacheTag
...@@ -15,6 +16,8 @@ related: ...@@ -15,6 +16,8 @@ related:
The `use cache` directive allows you to mark a route, React component, or a function as cacheable. It can be used at the top of a file to indicate that all exports in the file should be cached, or inline at the top of function or component to cache the return value. The `use cache` directive allows you to mark a route, React component, or a function as cacheable. It can be used at the top of a file to indicate that all exports in the file should be cached, or inline at the top of function or component to cache the return value.
> **Good to know:** For caching user-specific content that requires access to cookies or headers, see [`'use cache: private'`](/docs/app/api-reference/directives/use-cache-private).
## Usage ## Usage
`use cache` is a Cache Components feature. To enable it, add the [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComponents) option to your `next.config.ts` file: `use cache` is a Cache Components feature. To enable it, add the [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComponents) option to your `next.config.ts` file:
...@@ -104,6 +107,8 @@ When used at the top of a [layout](/docs/app/api-reference/file-conventions/layo ...@@ -104,6 +107,8 @@ When used at the top of a [layout](/docs/app/api-reference/file-conventions/layo
This means `use cache` cannot be used with [request-time APIs](/docs/app/getting-started/partial-prerendering#dynamic-rendering) like `cookies` or `headers`. This means `use cache` cannot be used with [request-time APIs](/docs/app/getting-started/partial-prerendering#dynamic-rendering) like `cookies` or `headers`.
> **Note:** If you need to cache content that depends on cookies, headers, or search params, use [`'use cache: private'`](/docs/app/api-reference/directives/use-cache-private) instead.
## `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.
......
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