gcloud compute backend-buckets update BACKEND_BUCKET_NAME [--cache-key-include-http-header=[HEADER_FIELD_NAME,…]] [--cache-key-query-string-whitelist=[QUERY_STRING,…]] [--cache-mode=CACHE_MODE] [--compression-mode=COMPRESSION_MODE] [--description=DESCRIPTION] [--edge-security-policy=EDGE_SECURITY_POLICY] [--[no-]enable-cdn] [--gcs-bucket-name=GCS_BUCKET_NAME] [--[no-]request-coalescing] [--signed-url-cache-max-age=SIGNED_URL_CACHE_MAX_AGE] [--bypass-cache-on-request-headers=BYPASS_CACHE_ON_REQUEST_HEADERS | --no-bypass-cache-on-request-headers] [--client-ttl=CLIENT_TTL | --no-client-ttl] [--custom-response-header=CUSTOM_RESPONSE_HEADER | --no-custom-response-headers] [--default-ttl=DEFAULT_TTL | --no-default-ttl] [--global | --region=REGION] [--max-ttl=MAX_TTL | --no-max-ttl] [--[no-]negative-caching | --no-negative-caching-policies | --negative-caching-policy=[[CODE=TTL],…]] [--serve-while-stale=SERVE_WHILE_STALE | --no-serve-while-stale] [GCLOUD_WIDE_FLAG …]
gcloud compute backend-buckets update is used to update backend
buckets.
BACKEND_BUCKET_NAME--cache-key-include-http-header=[HEADER_FIELD_NAME,…]--cache-key-query-string-whitelist=[QUERY_STRING,…]--cache-mode=CACHE_MODECACHE_MODE must be one of:
CACHE_ALL_STATICFORCE_CACHE_ALLUSE_ORIGIN_HEADERS--compression-mode=COMPRESSION_MODECOMPRESSION_MODE must be one of: DISABLED,
AUTOMATIC.
--description=DESCRIPTION--edge-security-policy=EDGE_SECURITY_POLICY--[no-]enable-cdn--enable-cdn to enable and --no-enable-cdn to disable.
--gcs-bucket-name=GCS_BUCKET_NAME--[no-]request-coalescingRequest coalescing (or collapsing) combines multiple concurrent cache fill requests into a small number of requests to the origin. This can improve performance by putting less load on the origin and backend infrastructure. However, coalescing adds a small amount of latency when multiple requests to the same URL are processed, so for latency-critical applications it may not be desirable.
Defaults to true.
Use--request-coalescing to enable and
--no-request-coalescing to disable.
--signed-url-cache-max-age=SIGNED_URL_CACHE_MAX_AGECache-Control: public, max-age=[TTL] header,
regardless of any existing Cache-Control header. The actual headers served in
responses will not be altered.
For example, specifying 12h will cause the responses to signed URL
requests to be cached in the CDN up to 12 hours. See $ gcloud topic datetimes for
information on duration formats.
--bypass-cache-on-request-headers=BYPASS_CACHE_ON_REQUEST_HEADERSThe cache is bypassed for all cdnPolicy.cacheMode settings.
Note that requests that include these headers will always fill from origin, and may result in a large number of cache misses if the specified headers are common to many requests.
Values are case-insensitive.
The header name must be a valid HTTP header field token (per RFC 7230).
For the list of restricted headers, see the list of required header name properties in How custom headers work.
A header name must not appear more than once in the list of added headers.--no-bypass-cache-on-request-headers--client-ttl=CLIENT_TTLThis allows you to set a shorter TTL for browsers/clients, and to have those clients revalidate content against Cloud CDN on a more regular basis, without requiring revalidation at the origin.
The value of clientTtl cannot be set to a value greater than that of maxTtl, but can be equal.
Any cacheable response has its max-age/s-maxage directives adjusted down to the client TTL value if necessary; an Expires header will be replaced with a suitable max-age directive.
The maximum allowed value is 31,622,400s (1 year).
When creating a new backend with CACHE_ALL_STATIC and the field is unset, or when switching to that mode and the field is unset, a default value of 3600 is used.
When the cache mode is set to "USE_ORIGIN_HEADERS", you must omit this field.--no-client-ttl--custom-response-header=CUSTOM_RESPONSE_HEADER--no-custom-response-headers--default-ttl=DEFAULT_TTLThe default value is 3600s for cache modes that allow a default TTL to be defined.
The value of defaultTtl cannot be set to a value greater than that of maxTtl, but can be equal.
When the cacheMode is set to FORCE_CACHE_ALL, the defaultTtl overwrites the TTL set in all responses.
A TTL of "0" means Always revalidate.
The maximum allowed value is 31,622,400s (1 year). Infrequently accessed objects may be evicted from the cache before the defined TTL.
When creating a new backend with CACHE_ALL_STATIC or FORCE_CACHE_ALL and the field is unset, or when updating an existing backend to use these modes and the field is unset, a default value of 3600 is used. When the cache mode is set to "USE_ORIGIN_HEADERS", you must omit this field.--no-default-ttl--global--region=REGIONcompute/region property value for this command invocation.
--max-ttl=MAX_TTLThe default value is 86400 for cache modes that support a max TTL.
Cache directives that attempt to set a max-age or s-maxage higher than this, or an Expires header more than maxTtl seconds in the future, are capped at the value of maxTtl, as if it were the value of an s-maxage Cache-Control directive.
A TTL of "0" means Always revalidate.
The maximum allowed value is 31,622,400s (1 year). Infrequently accessed objects may be evicted from the cache before the defined TTL.
When creating a new backend with CACHE_ALL_STATIC and the field is unset, or when updating an existing backend to use these modes and the field is unset, a default value of 86400 is used. When the cache mode is set to "USE_ORIGIN_HEADERS" or "FORCE_CACHE_ALL", you must omit this field.--no-max-ttl--[no-]negative-cachingNegative caching applies to a set of 3xx, 4xx, and 5xx status codes that are typically useful to cache.
Status codes not listed here cannot have their TTL explicitly set and aren't cached, in order to avoid cache poisoning attacks.
HTTP success codes (HTTP 2xx) are handled by the values of defaultTtl and maxTtl.
When the cache mode is set to CACHE_ALL_STATIC or USE_ORIGIN_HEADERS, these
values apply to responses with the specified response code that lack any
cache-control or expires headers.
When the cache mode is set to FORCE_CACHE_ALL, these values apply to all responses with the specified response code, and override any caching headers.
Cloud CDN applies the following default TTLs to these status codes:
These defaults can be overridden in cdnPolicy.negativeCachingPolicy.
Use--negative-caching to enable and
--no-negative-caching to disable.
--no-negative-caching-policies--negative-caching-policy=[[CODE=TTL],…]NegativeCaching must be enabled to config the negativeCachingPolicy.
If you omit the policy and leave negativeCaching enabled, Cloud CDN's default cache TTLs are used.
Note that when specifying an explicit negative caching policy, make sure that you specify a cache TTL for all response codes that you want to cache. Cloud CDN doesn't apply any default negative caching when a policy exists.
CODE is the HTTP status code to define a TTL against. Only HTTP
status codes 300, 301, 308, 404, 405, 410, 421, 451, and 501 can be specified as
values, and you cannot specify a status code more than once.
CODE. The maximum allowed value is 1800s (30 minutes),
noting that infrequently accessed objects may be evicted from the cache before
the defined TTL.
At most one of these can be specified:
--serve-while-stale=SERVE_WHILE_STALEThis setting defines the default serve-stale duration for any cached responses that do not specify a stale-while-revalidate directive. Stale responses that exceed the TTL configured here will not be served without first being revalidated with the origin. The default limit is 86400s (1 day), which will allow stale content to be served up to this limit beyond the max-age (or s-max-age) of a cached response.
The maximum allowed value is 604800 (1 week).
Set this to zero (0) to disable serve-while-stale.--no-serve-while-stale--access-token-file,
--account, --billing-project,
--configuration,
--flags-file,
--flatten, --format, --help, --impersonate-service-account,
--log-http,
--project, --quiet, --trace-token, --user-output-enabled,
--verbosity.
Run $ gcloud help for details.
gcloud alpha compute backend-buckets updategcloud beta compute backend-buckets updategcloud preview compute backend-buckets update
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 2026-05-27 UTC.