Unverified Commit 766467e0 authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

docs: link updateTag from cacheTag reference (#92379)

### What?
Add [`updateTag`](/docs/app/api-reference/functions/updateTag) to the
`cacheTag` API page: a **Related** link and a **Good to know** bullet
that explains when to use it (read-your-own-writes / immediate expiry)
and points to [Differences from
`revalidateTag`](https://nextjs.org/docs/app/api-reference/functions/updateTag#differences-from-revalidatetag).

### Why?
The bundled `cacheTag` doc only walked through `revalidateTag`, so the
two-API invalidation model was easy to miss. This keeps existing
`revalidateTag` wording and examples unchanged and adds a minimal
pointer to `updateTag` without duplicating its full reference.

### How?
- `related.links`: include `app/api-reference/functions/updateTag`.
- `## Good to know`: one imperative bullet + deep link to the comparison
section on the `updateTag` page.

## PR checklist (Improving Documentation)
- Prettier/ESLint ran via lint-staged on commit; run `pnpm prettier-fix`
if needed.
- Follow the docs contribution guide:
https://nextjs.org/docs/community/contribution-guide

Made with [Cursor](https://cursor.com)

---------
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent 4e3f35b3
...@@ -8,6 +8,7 @@ related: ...@@ -8,6 +8,7 @@ related:
- app/api-reference/config/next-config-js/cacheComponents - app/api-reference/config/next-config-js/cacheComponents
- app/api-reference/directives/use-cache - app/api-reference/directives/use-cache
- app/api-reference/functions/revalidateTag - app/api-reference/functions/revalidateTag
- app/api-reference/functions/updateTag
- app/api-reference/functions/cacheLife - app/api-reference/functions/cacheLife
--- ---
...@@ -59,7 +60,12 @@ export async function getData() { ...@@ -59,7 +60,12 @@ export async function getData() {
} }
``` ```
You can then purge the cache on-demand using [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) API in another function, for example, a [route handler](/docs/app/api-reference/file-conventions/route) or [Server Action](/docs/app/getting-started/mutating-data): You can then purge the cache on-demand from a [Server Function](/docs/app/getting-started/mutating-data) or [Route Handler](/docs/app/api-reference/file-conventions/route):
- Use [`updateTag`](/docs/app/api-reference/functions/updateTag) inside a Server Function for read-your-own-writes scenarios, where a user makes a change and the next read should fetch fresh data immediately.
- Use [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) when it is acceptable to serve stale data while revalidation happens in the background, or when revalidating from a route handler.
The example below uses `revalidateTag`:
```tsx filename="app/action.ts" switcher ```tsx filename="app/action.ts" switcher
'use server' 'use server'
......
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