Purging Vercel Cache
Learn how to invalidate and purge cached content on Vercel's CDN, including cache keys and manual purging options.
Cache purging is available on Enterprise, Pro, and Hobby plans.
Each request to Vercel's CDN has a cache key derived from the following:
- 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
orhttp
)
Since each deployment has a different cache key, you can promote a new deployment to production without affecting the cache of the previous deployment.
The cache key for Image Optimization behaves differently for static images and remote images.
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 are case-sensitive. The tags product
and Product
are treated as different tags.
Cache tags are scoped to your project. When you purge a tag, you can target production deployments, preview deployments, or both. By default, purging affects all cached responses across all deployments in that project that use that tag.
In some circumstances, you may need to delete all cached data and force revalidation. For example, you might have set a Cache-Control
to cache the response for a month but the content changes more frequently than once a month. You can do this by purging the cache:
- Under your project, go to the Settings tab.
- In the left sidebar, select Caches.
- In the CDN Cache section, click Purge CDN Cache.
- 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. A good use case for deleting the cache is when the origin has also been deleted, for example it returns a
404
or410
status code.
- In the dialog, enter one or more cache tags, separated by commas. You can use
*
to purge all cache tags. - Finally, click the Purge button in the dialog to confirm.
The purge event itself is not billed but it can temporarily increase Function Duration, Functions Invocations, Edge Function Executions, Fast Origin Transfer, Image Optimization Transformations, Image Optimization Cache Writes, and ISR Writes.
Purge is not the same as creating a new deployment because it will also purge Image Optimization content, which is usually preserved between deployments, as well as ISR content, which is often generated at build time for new deployments.
Hobby | Pro | Enterprise | |
---|---|---|---|
Rest API calls per minute | 5 | 5 | 5 |
Tags per Rest API call | 16 | 16 | 16 |
Tag character limit | 256 | 256 | 256 |
Tags per cached response | 128 | 128 | 128 |
Was this helpful?