Ifyou're calling this from a Server Action and need immediate expiration for read-your-own-writes, use `updateTag` instead:
```js
// In a Server Action
import { updateTag } from 'next/cache'
export async function createPost() {
// ... create post ...
// Immediately expire the cache
updateTag('posts')
}
```
## Revalidation Behavior
- **`revalidateTag(tag,"max")` (recommended)**: The tag entry is marked as stale, and the next time a resource with that tag is visited, it will use stale-while-revalidate semantics. This means the stale content is served while fresh content is fetched in the background.
- **`revalidateTag(tag,profile)`**: For advanced usage, you can specify any cache life profile that your application has defined in your `next.config` instead of `"max"`, allowing for custom revalidation behaviors.
- **`updateTag(tag)`**: Only available in Server Actions. The tag entry is expired immediately, and the next request to that resource will be a blocking revalidate/cache miss. This ensures read-your-own-writes consistency.
- **`revalidateTag(tag)` without second argument (deprecated)**: Same behavior as `updateTag`butshowsthisdeprecationwarning.
"868":"No reference found for param: %s in reference: %s",
"869":"No reference found for segment: %s with reference: %s",
"870":"refresh can only be called from within a Server Action. See more info here: https://nextjs.org/docs/app/api-reference/functions/refresh",
"871":"Image with src \"%s\" is using a query string which is not configured in images.localPatterns.\\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns"
"871":"Image with src \"%s\" is using a query string which is not configured in images.localPatterns.\\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns",
"872":"updateTag can only be called from within a Server Action. To invalidate cache tags in Route Handlers or other contexts, use revalidateTag instead. See more info here: https://nextjs.org/docs/app/api-reference/functions/updateTag",
"873":"Invalid profile provided \"%s\" must be configured under cacheLife in next.config or be \"max\""
'"revalidateTag" without the second argument is now deprecated, add second argument of "max" or use "updateTag". See more info here: https://nextjs.org/docs/messages/revalidate-tag-single-arg'
`Warning: expirePath received "${originalPath}" which exceeded max length of ${NEXT_CACHE_SOFT_TAG_MAX_LENGTH}. See more info here https://nextjs.org/docs/app/api-reference/functions/unstable_expirePath`
`Warning: a dynamic page path "${originalPath}" was passed to "expirePath", but the "type" parameter is missing. This has no effect by default, see more info here https://nextjs.org/docs/app/api-reference/functions/unstable_expirePath`
// TODO: change this after investigating why phase: 'action' is
"app-dir action handling fetch actions should handle calls to redirect() with a relative URL in a single pass",
"app-dir action handling fetch actions should handle calls to redirect() with external URLs",
"app-dir action handling fetch actions should handle redirects to routes that provide an invalid RSC response",
"app-dir action handling fetch actions should handle unstable_expirePath",
"app-dir action handling fetch actions should handle unstable_expireTag",
"app-dir action handling fetch actions should handle revalidatePath",
"app-dir action handling fetch actions should handle revalidateTag",
"app-dir action handling fetch actions should invalidate client cache on other routes when cookies.set is called",
"app-dir action handling fetch actions should invalidate client cache when path is revalidated",
"app-dir action handling fetch actions should invalidate client cache when tag is revalidated",
...
...
@@ -228,7 +228,7 @@
],
"failed":[],
"pending":[
"app-dir action handling fetch actions should handle unstable_expireTag + redirect",
"app-dir action handling fetch actions should handle revalidateTag + redirect",
"app-dir action handling server actions render client components client component imported action should support importing client components from actions"
],
"flakey":[],
...
...
@@ -299,8 +299,8 @@
"app-dir action handling fetch actions should handle calls to redirect() with a relative URL in a single pass",
"app-dir action handling fetch actions should handle calls to redirect() with external URLs",
"app-dir action handling fetch actions should handle redirects to routes that provide an invalid RSC response",
"app-dir action handling fetch actions should handle unstable_expirePath",
"app-dir action handling fetch actions should handle unstable_expireTag",
"app-dir action handling fetch actions should handle revalidatePath",
"app-dir action handling fetch actions should handle revalidateTag",
"app-dir action handling fetch actions should invalidate client cache on other routes when cookies.set is called",
"app-dir action handling fetch actions should invalidate client cache when path is revalidated",
"app-dir action handling fetch actions should invalidate client cache when tag is revalidated",
...
...
@@ -362,7 +362,7 @@
],
"failed":[],
"pending":[
"app-dir action handling fetch actions should handle unstable_expireTag + redirect",
"app-dir action handling fetch actions should handle revalidateTag + redirect",
"app-dir action handling server actions render client components client component imported action should support importing client components from actions"
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_cache is allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_cacheLife is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_cacheTag is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_expirePath is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_expireTag is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component revalidatePath is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component revalidateTag is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_noStore is allowed",
"Error overlay - RSC build errors next/root-params importing 'next/root-params' in a client component",
"Error overlay - RSC build errors next/root-params importing 'next/root-params' in a client component in a way that bypasses import analysis",
...
...
@@ -467,8 +467,8 @@
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_cache is allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_cacheLife is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_cacheTag is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_expirePath is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_expireTag is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages revalidatePath is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages revalidateTag is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_noStore is allowed",
"Error Overlay for server components compiler errors in pages importing 'next/headers' in pages",
"Error Overlay for server components compiler errors in pages importing 'next/root-params' in pages",
...
...
@@ -2613,8 +2613,8 @@
"app-dir action handling fetch actions should handle calls to redirect() with a relative URL in a single pass",
"app-dir action handling fetch actions should handle calls to redirect() with external URLs",
"app-dir action handling fetch actions should handle redirects to routes that provide an invalid RSC response",
"app-dir action handling fetch actions should handle unstable_expirePath",
"app-dir action handling fetch actions should handle unstable_expireTag",
"app-dir action handling fetch actions should handle revalidatePath",
"app-dir action handling fetch actions should handle revalidateTag",
"app-dir action handling fetch actions should invalidate client cache on other routes when cookies.set is called",
"app-dir action handling fetch actions should invalidate client cache when path is revalidated",
"app-dir action handling fetch actions should invalidate client cache when tag is revalidated",
...
...
@@ -2675,7 +2675,7 @@
],
"failed":[],
"pending":[
"app-dir action handling fetch actions should handle unstable_expireTag + redirect",
"app-dir action handling fetch actions should handle revalidateTag + redirect",
"app-dir action handling server actions render client components client component imported action should support importing client components from actions"
],
"flakey":[],
...
...
@@ -2742,8 +2742,8 @@
"app-dir action handling fetch actions should handle calls to redirect() with a relative URL in a single pass",
"app-dir action handling fetch actions should handle calls to redirect() with external URLs",
"app-dir action handling fetch actions should handle redirects to routes that provide an invalid RSC response",
"app-dir action handling fetch actions should handle unstable_expirePath",
"app-dir action handling fetch actions should handle unstable_expireTag",
"app-dir action handling fetch actions should handle revalidatePath",
"app-dir action handling fetch actions should handle revalidateTag",
"app-dir action handling fetch actions should invalidate client cache on other routes when cookies.set is called",
"app-dir action handling fetch actions should invalidate client cache when path is revalidated",
"app-dir action handling fetch actions should invalidate client cache when tag is revalidated",
...
...
@@ -2804,7 +2804,7 @@
],
"failed":[],
"pending":[
"app-dir action handling fetch actions should handle unstable_expireTag + redirect",
"app-dir action handling fetch actions should handle revalidateTag + redirect",
"app-dir action handling server actions render client components client component imported action should support importing client components from actions"
"app-dir action handling fetch actions should handle calls to redirect() with a relative URL in a single pass",
"app-dir action handling fetch actions should handle calls to redirect() with external URLs",
"app-dir action handling fetch actions should handle redirects to routes that provide an invalid RSC response",
"app-dir action handling fetch actions should handle unstable_expirePath",
"app-dir action handling fetch actions should handle unstable_expireTag",
"app-dir action handling fetch actions should handle revalidatePath",
"app-dir action handling fetch actions should handle revalidateTag",
"app-dir action handling fetch actions should invalidate client cache on other routes when cookies.set is called",
"app-dir action handling fetch actions should invalidate client cache when path is revalidated",
"app-dir action handling fetch actions should invalidate client cache when tag is revalidated",
...
...
@@ -225,7 +225,7 @@
],
"failed":[],
"pending":[
"app-dir action handling fetch actions should handle unstable_expireTag + redirect",
"app-dir action handling fetch actions should handle revalidateTag + redirect",
"app-dir action handling server actions render client components client component imported action should support importing client components from actions"
],
"flakey":[],
...
...
@@ -294,8 +294,8 @@
"app-dir action handling fetch actions should handle calls to redirect() with a relative URL in a single pass",
"app-dir action handling fetch actions should handle calls to redirect() with external URLs",
"app-dir action handling fetch actions should handle redirects to routes that provide an invalid RSC response",
"app-dir action handling fetch actions should handle unstable_expirePath",
"app-dir action handling fetch actions should handle unstable_expireTag",
"app-dir action handling fetch actions should handle revalidatePath",
"app-dir action handling fetch actions should handle revalidateTag",
"app-dir action handling fetch actions should invalidate client cache on other routes when cookies.set is called",
"app-dir action handling fetch actions should invalidate client cache when path is revalidated",
"app-dir action handling fetch actions should invalidate client cache when tag is revalidated",
...
...
@@ -357,7 +357,7 @@
],
"failed":[],
"pending":[
"app-dir action handling fetch actions should handle unstable_expireTag + redirect",
"app-dir action handling fetch actions should handle revalidateTag + redirect",
"app-dir action handling server actions render client components client component imported action should support importing client components from actions"
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_cache is allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_cacheLife is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_cacheTag is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_expirePath is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_expireTag is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component revalidatePath is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component revalidateTag is not allowed",
"Error overlay - RSC build errors importing 'next/cache' APIs in a client component unstable_noStore is allowed",
"Error overlay - RSC build errors should allow to use and handle rsc poisoning client-only",
"Error overlay - RSC build errors should allow to use and handle rsc poisoning server-only",
...
...
@@ -2275,8 +2275,8 @@
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_cache is allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_cacheLife is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_cacheTag is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_expirePath is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_expireTag is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages revalidatePath is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages revalidateTag is not allowed",
"Error Overlay for server components compiler errors in pages importing 'next/cache' APIs in pages unstable_noStore is allowed",
"Error Overlay for server components compiler errors in pages importing 'next/headers' in pages",
"Error Overlay for server components compiler errors in pages importing 'server-only' in pages",
...
...
@@ -4216,8 +4216,8 @@
"app-dir action handling fetch actions should handle calls to redirect() with a relative URL in a single pass",
"app-dir action handling fetch actions should handle calls to redirect() with external URLs",
"app-dir action handling fetch actions should handle redirects to routes that provide an invalid RSC response",
"app-dir action handling fetch actions should handle unstable_expirePath",
"app-dir action handling fetch actions should handle unstable_expireTag",
"app-dir action handling fetch actions should handle revalidatePath",
"app-dir action handling fetch actions should handle revalidateTag",
"app-dir action handling fetch actions should invalidate client cache on other routes when cookies.set is called",
"app-dir action handling fetch actions should invalidate client cache when path is revalidated",
"app-dir action handling fetch actions should invalidate client cache when tag is revalidated",
...
...
@@ -4279,7 +4279,7 @@
],
"failed":[],
"pending":[
"app-dir action handling fetch actions should handle unstable_expireTag + redirect",
"app-dir action handling fetch actions should handle revalidateTag + redirect",
"app-dir action handling server actions render client components client component imported action should support importing client components from actions"
],
"flakey":[],
...
...
@@ -4344,8 +4344,8 @@
"app-dir action handling fetch actions should handle calls to redirect() with a relative URL in a single pass",
"app-dir action handling fetch actions should handle calls to redirect() with external URLs",
"app-dir action handling fetch actions should handle redirects to routes that provide an invalid RSC response",
"app-dir action handling fetch actions should handle unstable_expirePath",
"app-dir action handling fetch actions should handle unstable_expireTag",
"app-dir action handling fetch actions should handle revalidatePath",
"app-dir action handling fetch actions should handle revalidateTag",
"app-dir action handling fetch actions should invalidate client cache on other routes when cookies.set is called",
"app-dir action handling fetch actions should invalidate client cache when path is revalidated",
"app-dir action handling fetch actions should invalidate client cache when tag is revalidated",
...
...
@@ -4407,7 +4407,7 @@
],
"failed":[],
"pending":[
"app-dir action handling fetch actions should handle unstable_expireTag + redirect",
"app-dir action handling fetch actions should handle revalidateTag + redirect",
"app-dir action handling server actions render client components client component imported action should support importing client components from actions"