CDN cache revalidation allows you to refresh cached content in your environment after modifying content or configuration. An environment may include multiple domains that share the same CDN settings. When you revalidate the cache, the CDN checks whether any content has changed since it was last cached. If updates are detected, the CDN fetches the latest content from the origin server and updates its cache. Otherwise, it continues serving the existing cached version. This ensures visitors always see the most up-to-date content.
Note: Each time you redeploy your environment, Launch automatically purges the CDN cache. This ensures that users always receive the most up-to-date content.
To revalidate the CDN cache for a website using URL path, you must provide the following:
The revalidation path is the URL path that you can revalidate across all the domains in your environment. For example, if you have an environment that consists of https://example.com, https://example.net, and https://example.org, and your revalidation path is /blog, then the CDN revalidates https://example.com/blog, https://example.net/blog, and https://example.org/blog.
The boolean value Is Prefix indicates whether you can revalidate only the exact path or also all the nested paths under it. For example, if your revalidation path is /blog and you set Is Prefix to true, then the CDN revalidates https://example.com/blog, and also all the pages under it, such as https://example.com/blog/post1, https://example.com/blog/post2, etc. If you set Is Prefix to false, then the CDN revalidates only https://example.com/blog. Similarly, CDN cache will also be revalidated for all other domains that are a part of the same environment.
Cache-Tags allow you to associate one or more tags with cached resources. These tags are included in the response headers, separated by commas.
Example:
Cache-Tag: product-123, product-456Instead of purging dozens or hundreds of individual URLs when a resource changes, you can purge all content sharing the same tag with a single API call.
Launch treats duplicate Cache-Tags in a single purge request as a single operation. Duplicate tags are not reprocessed.
Hostnames allow you to selectively purge cached resources for specific domains.
If your site is configured with multiple domains, such as domain1.com, domain2.com, and domain3.com, but a change should only affect domain1.com and domain2.com, you can purge only those domains without affecting the rest.
Tip: For more targeted and flexible cache purging, purge cache using Cache-Tags or Hostnames.
| Input | Type | Description |
|---|---|---|
| cachePath | string | URL path to purge (with optional isPrefix) |
| cacheTags | string[] | Array of Cache-Tags to purge |
| hostnames | string[] | Array of hostnames (domains) to target |
Note: You can pass only one of the inputs.
To revalidate the CDN cache for an environment, you can use the Revalidate CDN Cache action in the Automate Launch connector.
Additional Resource: For detailed information on creating the Revalidate CDN Cache action in Automate, refer to the Launch Connector document.
import { NextResponse } from 'next/server';
export async function GET() {
const data = await fetchBlogPost();
const response = NextResponse.json(data);
// Set Cache-Tag header
response.headers.set("Cache-Tag", "blog-post-123");
return response;
}{
"cacheTags": ["blog-post-123"]
}{
"hostnames": ["domain1.com", "domain2.com"]
}