CDN Cache

Purging Vercel CDN Cache
Purge CDN Cache
Each request to Vercel's CDN has a cache key derived from the following:
all plans
Learn how to invalidate and delete cached content on Vercel's CDN, including cache keys and manual purging options.
- The request method (such as GET, POST, etc)
- The request URL (query strings are ignored for static files)
- The host domain
- The unique deployment URL
- The scheme (whether it's https or http)
Since each deployment has a different cache key, you can promote a new deployment to production without affecting the cache of the previous deployment.
static
images and
remote
images.
Cache keys are not configurable. To purge the cache you must configure cache tags.
Understanding cache purging
When you purge by cache tag, Vercel purges all three types of cache: CDN cache, Runtime Cache, and Data Cache. This ensures your content updates consistently across all layers.
When you invalidate a cache tag, all cached content associated with that tag is marked as stale. The next request serves the stale content instantly while revalidation happens in the background. This approach has no latency impact for users while ensuring content gets updated.
When you delete a cache tag, the cached entries are marked for deletion. The next request fetches content from your origin before responding to the user. This can slow down the first request after deletion. If many users request the same deleted content simultaneously, it can create a cache stampede where multiple requests hit your origin at once.
Cache tags (sometimes called surrogate keys) are user-defined strings that can be assigned to cached responses. These tags can later be used to purge the CDN cache.
For example, you may have a product with id 123 that is displayed on multiple pages such as /products/123/overview, /products/123/reviews, etc. If you add a unique cache tag to those pages, such as product123, you can invalidate that tag when the content of the product changes. You may want to add another tag products to invalidate all products at once.
There are several ways to add cache tags to a response:
- Vercel-Cache-Tag response header: Set the Vercel-Cache-Tag header on responses from Vercel Functions or external rewrites. The value is a comma-separated list of tags.
- addCacheTag() function: Import addCacheTag from @vercel/functions and pass in your tag.
- cacheTag() function (Next.js only): Import cacheTag from next/cache and pass in your tag.
The example below sets both Vercel-CDN-Cache-Control and Vercel-Cache-Tag in a Vercel Function to ensure the response is cached and can be purged on-demand by tag at some point in the future:
exportdefault {
};
headers: {
asyncfetch(request) {
constproduct=awaitres.json();
returnResponse.json(product, {
'Vercel-CDN-Cache-Control':'public, max-age=86400',
},
});
},
constid=newURL(request.url).searchParams.get('id');
'Vercel-Cache-Tag':`product-${id},products`,
constres=awaitfetch(`https://api.example.com/${id}`);
Vercel's CDN can also cache and purge responses originating outside of Vercel by using external rewrites with the same headers.
Functions using ISR don't have access to the raw Response headers. You can add cache tags by importing addCacheTag from @vercel/functions to add tags at runtime.
If you're using Next.js, you can add cache tags by importing cacheTag from next/cache instead.
Cache tags are case-sensitive, meaning product and Product are treated as different tags.
Cache tags must not contain commas. The comma character ( ,) is reserved as a delimiter in the Vercel-Cache-Tag header and in API calls that accept multiple tags. If a tag contains a comma, it's interpreted as two separate tags.
Cache tags are scoped to your project and environment (production or preview).
When you purge a tag with the REST API, you can optionally provide a target environment such as preview or production (default is all environments).
When you purge a tag using @vercel/functions at runtime, the function's current environment is used which is derived from the deployment url that invoked the function.
When using rewrites from a parent project to a child project and both are on the same team, cached responses on the parent project will also include the corresponding tags from the child project.
Vercel's CDN automatically adds system cache tags to certain cached responses so you can easily purge by tag at your convenience.
For example, a cached response from Image Optimization automatically adds the source image as a cache tag to each transformed image. These may contain commas, unlike user-defined cache tags.
This allows you to purge by a single source image without purging the entire project.
Programmatically purging CDN Cache
You can purge Vercel CDN cache in any of the following ways:
- next/cache: Use helper methods like revalidatePath(), revalidateTag(), or updateTag()
- @vercel/functions: Use helper methods like invalidateByTag(), dangerouslyDeleteByTag(), invalidateBySrcImage(), or dangerouslyDeleteBySrcImage()
- Vercel CLI: Use the vercel cache invalidate command or vercel cache dangerously-delete command with --tag or --srcimg options
- REST API: Make direct API calls to the edge cache endpoint like /invalidate-by-tag, /dangerously-delete-by-tag, /invalidate-by-source-image, or /dangerously-delete-by-source-image
Manually purging Vercel CDN Cache
In some circumstances, you may need to purge cached responses and force revalidation. For example, you might set a Cache-Control value that caches a response for a month, then update the content before that month ends. You can purge the cache from the dashboard:
- Under your project, open CDN in the sidebar, then select Caches.
- In the Purge cache section, choose what you want to purge.
- Click Purge.
- In the dialog, you'll see two options:
- Invalidate: Marks a cache tag as stale, causing cache entries associated with that tag to be revalidated in the background on the next request. This is the recommended method for most use cases.
- Delete: Marks a cache tag as deleted, causing cache entries associated with that tag to be revalidated in the foreground on the next request. Use this method with caution because one tag can be associated with many paths and deleting the cache can cause many concurrent requests to the origin leading to cache stampede problem. This option is for advanced use cases and is not recommended; prefer using Invalidate instead.
- In the dialog, you'll see a dropdown with two options:
- Cache Tag: Purge cached responses associated with a specific user-defined tag.
- Source Image: Purge Image Optimization transformed images based on the original source image URL.
- In the dialog, enter a tag or source image in the input. You can use * to purge the entire project.
- Finally, click the Purge button in the dialog to confirm.
Limits
UTF-8 bytes per tag
16
Vercel does not bill the purge event itself, but purging can temporarily increase related usage, such as Active CPU, Provisioned Memory, Function Invocations, Fast Origin Transfer, Image Optimization Transformations, Image Optimization Cache Writes, and ISR Writes.
Maximum
256
Tags per cached response
UTF-8 bytes per source image tag
Tags per bulk REST API call
128
1013
Last updated September 3, 2026
Cross-link map: Purging Vercel CDN Cache (/docs/caching/cdn-cache/purge)From the Vercel docs graph (built 2026-09-21T05:26:59.511Z), spanning vercel.com docs + KB, nextjs.org, ai-sdk.dev, and other Vercel documentation sites. Full graph as JSON: https://vercel.com/docs/graph.jsonSemantically closest pagesManage cache tags for external origins — Learn how to use cache tags to optimally serve fresh content on Vercel when content from your external origin changesInvalidate the CDN cache by tagvercel cache — Learn how to manage cache for your project using the vercel cache CLI command.Tag-based cache invalidation now available for all responses@vercel/functions API Reference \(Node.js\) — Learn about available APIs when working with Vercel Functions.PrerequisitesCaching — Learn how Vercel caches content across multiple layers to deliver fast responses and reduce load on your backend.This page links to (12)cacheTag — Learn how to use the cacheTag function to manage cache invalidation in your Next.js application.Account Management — Learn how to manage your Vercel account and team members.vercel cache — Learn how to manage cache for your project using the vercel cache CLI command.Accessing Deployments through Generated URLs — When you create a new deployment, Vercel will automatically generate a unique URL which you can use to access that partiPromoting Deployments — Learn how to promote deployments to production on Vercel.Vercel Functions — Build API routes, webhooks, and agent request handlers with Vercel Functions, then test and debug them with Vercel CLI.@vercel/functions API Reference \(Node.js\) — Learn about available APIs when working with Vercel Functions.Image Optimization with Vercel — Transform and optimize images to improve page load performance.Incremental Static Regeneration \(ISR\) — ISR serves cached static pages while regenerating content in the background. Vercel\\Projects overview — A project is where you deploy and operate frontend apps, APIs, backends, containers, and agent workloads on Vercel.Invalidate by tag — POST /v1/edge-cache/invalidate-by-tags — Marks a cache tag as stale, causing cache entries associated with that tag to bRewrites on Vercel — Learn how to use rewrites to send users to different URLs without modifying the visible URL.Pages that link here (13)By site: vercel-changelog (1) · vercel-kb (3) · vercel-docs (9)From vercel-changelogVercel CDN now respects Cache-Control headers from external origins by defaultFrom vercel-kbHow to add per-request CSP nonces to CDN-cached HTML on Vercel — Use Routing Middleware and a self-fetch to add a fresh CSP nonce to cached HTML without rendering the page again on everHow to reduce ISR revalidation costs — Reduce ISR costs by analyzing Incremental Static Regeneration \(ISR\) behavior to find pages and tags that revalidate toHow to reduce Vercel Image Optimization costs — Learn how to reduce Vercel Image Optimization costs in Next.js by tuning cache TTLs, image sizes, formats, and quality.From vercel-docsCaching — Learn how Vercel caches content across multiple layers to deliver fast responses and reduce load on your backend.Cache Status and Reasons — Understand the cache status and reason shown for each request in Vercel logs, and what causes a response to miss, bypassVercel CDN Cache — Learn how Vercel's CDN cache stores your content across a global network to reduce latency and origin load.Vercel CDN overview — Vercel's CDN is a globally distributed platform that handles routing, caching, security, and compression for every deplovercel cache — Learn how to manage cache for your project using the vercel cache CLI command.@vercel/functions API Reference \(Node.js\) — Learn about available APIs when working with Vercel Functions.Image Optimization with Vercel — Transform and optimize images to improve page load performance.Serving Static Files — Serve tenant-specific static files like robots.txt, sitemap.xml, and llms.txt dynamically using route handlers.Rewrites on Vercel — Learn how to use rewrites to send users to different URLs without modifying the visible URL.
Was this helpful?