diff --git a/docs/01-app/03-api-reference/04-functions/cacheTag.mdx b/docs/01-app/03-api-reference/04-functions/cacheTag.mdx index 5fdbf1105c142..dc65be606b63d 100644 --- a/docs/01-app/03-api-reference/04-functions/cacheTag.mdx +++ b/docs/01-app/03-api-reference/04-functions/cacheTag.mdx @@ -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 --- @@ -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'