Skip to content
8 changes: 7 additions & 1 deletion docs/01-app/03-api-reference/04-functions/cacheTag.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ related:
- app/api-reference/config/next-config-js/cacheComponents
- app/api-reference/directives/use-cache
- app/api-reference/functions/revalidateTag
- app/api-reference/functions/updateTag
- app/api-reference/functions/cacheLife
---

Expand Down Expand Up @@ -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
'use server'
Expand Down
Loading