Stay organized with collections Save and categorize content based on your preferences.
This page describes how to invalidate your Cloud CDN cached content.
For example, if a file located at /images/file.jpg
has been cached and needs to be invalidated, you can use several methods to invalidate it, depending on whether you want to affect only that file or a wider scope. In each case, you can invalidate for all hostnames or for only one hostname.
To learn more about cache invalidation, see Cache invalidation overview.
Before you beginYou can use the Google Cloud CLI or the Google Cloud console to perform invalidations.
You can access the Google Cloud CLI in two ways:
Install the Google Cloud CLI by following the instructions at Installing with apt-get
. If you haven't used the Google Cloud CLI previously, first run gcloud init
to authenticate.
Use Cloud Shell, which comes with gcloud
already installed.
To perform this task, you must have been granted the following permissions or the following IAM roles.
Permissions
compute.urlMaps.get
compute.urlMaps.invalidateCache
compute.urlMaps.list
Roles
roles/compute.networkAdmin
roles/compute.loadBalancerAdmin
To create a custom role with the required permissions, see Creating and managing custom roles.
To add a predefined role, use the IAM quickstart.
Note: If you're using a global external Application Load Balancer with Shared VPC cross-project service referencing, see Invalidation with Shared VPC cross-project service referencing. Invalidate only one file ConsoleIn the Google Cloud console, go to the Cloud CDN page.
Click an origin.
Click the Cache invalidation tab.
For Associated load balancers, select the load balancer.
Under Specify objects to invalidate, do the following:
/images/file.jpg
.Click Invalidate.
Use the gcloud compute url-maps invalidate-cdn-cache
command.
To specify only one file for invalidation, use the --path
flag with the filename.
gcloud compute url-maps invalidate-cdn-cache URL_MAP_NAME \ --path "/images/file.jpg"
Replace URL_MAP_NAME
with the name of your URL map. To list your URL maps, use the gcloud compute url-maps list
command.
To invalidate for only one host, add the --host
flag—for example, --host host1.com
.
gcloud compute url-maps invalidate-cdn-cache URL_MAP_NAME \ --host host1.com \ --path "/images/file.jpg"
By default, the Google Cloud CLI waits until the invalidation has completed. To perform the invalidation in the background, append --async
to the command line.
Use the urlMaps.invalidateCache
method.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/urlMaps/URL_MAP_NAME/invalidateCache
Replace the following:
PROJECT_ID
: your Google Cloud console project IDURL_MAP_NAME
: the name of the URL mapTo specify a file for invalidation, use the following sample JSON request body:
{ "path": "/images/file.jpg" }
To invalidate the file for only one host, use the following sample JSON request body:
{ "host": "host1.com", "path": "/images/file.jpg" }Invalidate the whole directory Console
In the Google Cloud console, go to the Cloud CDN page.
Click an origin.
Click the Cache invalidation tab.
For Associated load balancers, select the load balancer.
Under Specify objects to invalidate, do the following:
/images/*
.Click Invalidate.
Use the gcloud compute url-maps invalidate-cdn-cache
command.
gcloud compute url-maps invalidate-cdn-cache URL_MAP_NAME \ --path "/images/*"
Replace URL_MAP_NAME
with the name of your URL map.
To invalidate for only one host, add the --host
flag—for example, --host host1.com
.
gcloud compute url-maps invalidate-cdn-cache URL_MAP_NAME \ --host host1.com \ --path "/images/*"API
Use the urlMaps.invalidateCache
method.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/urlMaps/URL_MAP_NAME/invalidateCache
Replace the following:
PROJECT_ID
: your Google Cloud console project IDURL_MAP_NAME
: the name of the URL mapTo specify a directory for invalidation, use the following sample JSON request body:
{ "path": "/images/*" }
To invalidate a directory for only one host, use the following sample JSON request body:
{ "host": "host1.com", "path": "/images/*" }Console
In the Google Cloud console, go to the Cloud CDN page.
Click an origin.
Click the Cache invalidation tab.
For Associated load balancers, select the load balancer.
Under Specify objects to invalidate, for Cache tags, specify one or more tags to invalidate. Use spaces or commas to separate tags.
Click Invalidate.
Use the gcloud beta compute url-maps invalidate-cdn-cache
command.
gcloud beta compute url-maps invalidate-cdn-cache URL_MAP_NAME \ --tags=TAGS
Replace the following:
URL_MAP_NAME
: the name of the URL mapTAGS
: a tag or a comma-separated list of tags; alternatively, you can specify this flag up to 10 timesFor example, if the backend response includes a Cache-Tag
header with an opaque user ID, such as a UUID4 or another form of GUID, you can invalidate all content for a specific user by using the tag
flag. Additionally, to invalidate content for only one host, such as for your staging environment, add the --host
flag.
gcloud beta compute url-maps invalidate-cdn-cache url_map_1 \ --tags="1115b8f4-f804-4861-9629-8cb9aecdeeb3" \ --host="host1.com"API
Use the urlMaps.invalidateCache
method.
POST https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/global/urlMaps/URL_MAP_NAME/invalidateCache
Replace the following:
PROJECT_ID
: your Google Cloud console project IDURL_MAP_NAME
: the name of the URL mapTo specify cache tags for invalidation, use the following sample JSON request body:
{ "cacheTags": [ "tag1", "tag2" ] }
You can specify a single tag or a comma-separated list of tags.
To invalidate by cache tags for only one host, use the following sample JSON request body:
{ "host": "host1.com", "path": "tag1,tag2" }Invalidate everything
Although you can invalidate everything, it's potentially risky. Evaluate your requirements carefully before you proceed.
ConsoleIn the Google Cloud console, go to the Cloud CDN page.
Click an origin.
Click the Cache invalidation tab.
For Associated load balancers, select the load balancer.
Under Specify objects to invalidate, do the following:
/*
.Click Invalidate and then click Confirm to indicate that you want Cloud CDN to invalidate everything.
Use the gcloud compute url-maps invalidate-cdn-cache
command.
gcloud compute url-maps invalidate-cdn-cache URL_MAP_NAME \ --path "/*"
Replace the following:
URL_MAP_NAME
: the name of the URL map/*
: the URL path that you want to invalidate; doesn't include the hostname; the path can use an explicit filename or an asterisk as a wildcardTo invalidate for only one host, add the --host
flag—for example, --host host1.com
.
gcloud compute url-maps invalidate-cdn-cache URL_MAP_NAME \ --host host1.com \ --path "/*"API
Use the urlMaps.invalidateCache
method.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/urlMaps/URL_MAP_NAME/invalidateCache
Replace the following:
PROJECT_ID
: your Google Cloud console project IDURL_MAP_NAME
: the name of the URL mapTo specify a URL path for invalidation, use the following sample JSON request body:
{ "path": "/*" }
To invalidate the URL path for only one host, use the following sample JSON request body:
{ "host": "host1.com", "path": "/*" }See the status of your invalidation request
Cloud CDN emits two log lines per invalidation, one when the invalidation is accepted and the other when it's complete. The first has the host and path information.
To see the status of your invalidation request or find a definitive list of recently submitted requests, you can use Cloud Logging or Cloud Monitoring.
ConsoleIn the Google Cloud console, go to the Cloud CDN page.
Click an origin.
Click the Cache invalidation tab.
To see the status and results of the invalidation request, click Go to Cloud Logging.
The following is a sample command that uses Logging:
gcloud logging read 'protoPayload.methodName="v1.compute.urlMaps.invalidateCache"' \ --limit=10
The following is a sample query that uses Monitoring:
protoPayload.serviceName="compute.googleapis.com" protoPayload.methodName="v1.compute.urlMaps.invalidateCache"What's next
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This page outlines how to invalidate cached content in Cloud CDN, whether it's a single file, an entire directory, or all content, using the Google Cloud console, the Google Cloud CLI, or the API."],["You can choose to invalidate content for all hostnames or for a specific hostname by specifying the hostname as part of the path or with the `--host` flag."],["Content can be invalidated by specifying a file path, a directory path with a wildcard (`*`), or by using cache tags, allowing for targeted removal of cached content."],["To invalidate all content, use the root path with a wildcard (`/*`), and this can be done for all hostnames or for a single specified hostname."],["You can track the status of your invalidation requests using Cloud Logging or Cloud Monitoring to ensure that content has been successfully invalidated."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4