KEMBAR78
docs: added `use cache: remote` docs by wyattjoh · Pull Request #85145 · vercel/next.js · GitHub
Skip to content

Conversation

wyattjoh
Copy link
Member

@wyattjoh wyattjoh commented Oct 21, 2025

Added documentation for use cache: remote.

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. labels Oct 21, 2025
@wyattjoh wyattjoh marked this pull request as ready for review October 21, 2025 01:34
@github-actions
Copy link
Contributor

github-actions bot commented Oct 22, 2025

All broken links are now fixed, thank you!

async function getProductPrice(productId: string) {
'use cache: remote'
cacheTag(`product-price-${productId}`)
cacheLife({ stale: 3600 }) // 1 hour
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean revalidate? I thought stale was the client-side cache.


When Next.js encounters certain APIs like [`connection()`](/docs/app/api-reference/functions/connection), [`cookies()`](/docs/app/api-reference/functions/cookies), or [`headers()`](/docs/app/api-reference/functions/headers), the context becomes "dynamic". In a dynamic context:

1. **Regular `use cache` stops working** - it won't cache anything
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention that it'll error in development? Because the fear is that this will happen silently.


> **Good to know:** Without `'use cache: remote'`, functions in dynamic contexts would execute on every request, potentially creating performance bottlenecks. Remote caching eliminates this issue by storing results in server-side cache handlers.

### Storage behavior
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhere in this section, you may want to link to how to configure cache handlers. Otherwise, it's not actionable.

}
```

> **Good to know**:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this section is repetitive, since we already mentioned when to use each.
I do like the distinction between using cacheTag to revalidate, and cacheLife to expire, good wording.

icyJoseph and others added 3 commits October 22, 2025 14:34
Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
@wyattjoh wyattjoh merged commit 27a3fa7 into canary Oct 22, 2025
76 checks passed
@wyattjoh wyattjoh deleted the docs/use-cache-remote branch October 22, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants