gcloud beta compute backend-buckets create Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud beta compute backend-buckets create - create a backend bucket
- SYNOPSIS
gcloud beta compute backend-buckets createBACKEND_BUCKET_NAME--gcs-bucket-name=GCS_BUCKET_NAME[--bypass-cache-on-request-headers=BYPASS_CACHE_ON_REQUEST_HEADERS][--cache-key-include-http-header=[HEADER_FIELD_NAME,…]][--cache-key-query-string-whitelist=[QUERY_STRING,…]][--cache-mode=CACHE_MODE][--client-ttl=CLIENT_TTL][--compression-mode=COMPRESSION_MODE][--custom-response-header=CUSTOM_RESPONSE_HEADER][--default-ttl=DEFAULT_TTL][--description=DESCRIPTION][--[no-]enable-cdn][--load-balancing-scheme=LOAD_BALANCING_SCHEME][--max-ttl=MAX_TTL][--[no-]negative-caching][--negative-caching-policy=[[CODE=TTL],…]][--[no-]request-coalescing][--resource-manager-tags=[KEY=VALUE,…]][--serve-while-stale=SERVE_WHILE_STALE][--signed-url-cache-max-age=SIGNED_URL_CACHE_MAX_AGE][--global|--region=REGION][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(BETA)gcloud beta compute backend-buckets createisused to create backend buckets. Backend buckets define Google Cloud Storagebuckets that can serve content. URL maps define which requests are sent to whichbackend buckets.To create a global backend bucket, run either of the following:
gcloudbetacomputebackend-bucketscreatemy-backend-bucket--gcs-bucket-namegcs-bucket-1--globalgcloudbetacomputebackend-bucketscreatemy-backend-bucket--gcs-bucket-namegcs-bucket-1To create a regional backend bucket, run the following:
gcloudbetacomputebackend-bucketscreatemy-backend-bucket--gcs-bucket-namegcs-bucket-1--region=us-central1- POSITIONAL ARGUMENTS
BACKEND_BUCKET_NAME- Name of the backend bucket to create.
- REQUIRED FLAGS
--gcs-bucket-name=GCS_BUCKET_NAME- The name of the Google Cloud Storage bucket to serve from. The storage bucketmust be in the same project.
- OPTIONAL FLAGS
--bypass-cache-on-request-headers=BYPASS_CACHE_ON_REQUEST_HEADERS- Bypass the cache when the specified request headers are matched - e.g. Pragma orAuthorization headers. Up to 5 headers can be specified.
The cache is bypassed for all cdnPolicy.cacheMode settings.
Note that requests that include these headers will always fill from origin, andmay result in a large number of cache misses if the specified headers are commonto 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 nameproperties inHowcustom headers work.
A header name must not appear more than once in the list of added headers.
--cache-key-include-http-header=[HEADER_FIELD_NAME,…]- Specifies a comma-separated list of HTTP headers, by field name, to include incache keys. Only the request URL is included in the cache key by default.
--cache-key-query-string-whitelist=[QUERY_STRING,…]- Specifies a comma-separated list of query string parameters to include in cachekeys. Default parameters are always included. '&' and '=' are percentencoded and not treated as delimiters.
--cache-mode=CACHE_MODE- Specifies the cache setting for all responses from this backend.
CACHE_MODEmust be one of:CACHE_ALL_STATIC- Automatically cache static content, including common image formats, media (videoand audio), web assets (JavaScript and CSS). Requests and responses that aremarked as uncacheable, as well as dynamic content (including HTML), aren'tcached.
FORCE_CACHE_ALL- Cache all content, ignoring any "private", "no-store" or "no-cache" directivesin Cache-Control response headers. Warning: this may result in Cloud CDN cachingprivate, per-user (user identifiable) content. You should only enable this onbackends that are not serving private or dynamic content, such as storagebuckets.
USE_ORIGIN_HEADERS- Require the origin to set valid caching headers to cache content. Responseswithout these headers aren't cached at Google's edge, and require a full trip tothe origin on every request, potentially impacting performance and increasingload on the origin server.
--client-ttl=CLIENT_TTL- Specifies a separate client (for example, browser client) TTL, separate from theTTL for Cloud CDN's edge caches.
This allows you to set a shorter TTL for browsers/clients, and to have thoseclients revalidate content against Cloud CDN on a more regular basis, withoutrequiring revalidation at the origin.
The value of clientTtl cannot be set to a value greater than that of maxTtl, butcan be equal.
Any cacheable response has its max-age/s-maxage directives adjusted down to theclient TTL value if necessary; an Expires header will be replaced with asuitable 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, orwhen switching to that mode and the field is unset, a default value of 3600 isused.
When the cache mode is set to "USE_ORIGIN_HEADERS", you must omit this field.
--compression-mode=COMPRESSION_MODE- Compress text responses using Brotli or gzip compression, based on the client'sAccept-Encoding header. Two modes are supported: AUTOMATIC (recommended) -automatically uses the best compression based on the Accept-Encoding header sentby the client. In most cases, this will result in Brotli compression beingfavored. DISABLED - disables compression. Existing compressed responses cachedby Cloud CDN will not be served to clients.
COMPRESSION_MODEmust be one of:DISABLED,AUTOMATIC. --custom-response-header=CUSTOM_RESPONSE_HEADER- Custom headers that the external Application Load Balancer adds to proxiedresponses. For the list of headers, seeCreatingcustom headers.
Variables are not case-sensitive.
--default-ttl=DEFAULT_TTL- Specifies the default TTL for cached content served by this origin for responsesthat do not have an existing valid TTL (max-age or s-maxage).
The default value is 3600s for cache modes that allow a default TTL to bedefined.
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 TTLset in all responses.
A TTL of "0" means Always revalidate.
The maximum allowed value is 31,622,400s (1 year). Infrequently accessed objectsmay be evicted from the cache before the defined TTL.
When creating a new backend with CACHE_ALL_STATIC or FORCE_CACHE_ALL and thefield is unset, or when updating an existing backend to use these modes and thefield is unset, a default value of 3600 is used. When the cache mode is set to"USE_ORIGIN_HEADERS", you must omit this field.
--description=DESCRIPTION- An optional, textual description for the backend bucket.
--[no-]enable-cdn- Enable Cloud CDN for the backend bucket. Cloud CDN can cache HTTP responses froma backend bucket at the edge of the network, close to users. Use
--enable-cdnto enable and--no-enable-cdnto disable. --load-balancing-scheme=LOAD_BALANCING_SCHEME- The load balancing scheme of the backend bucket. If left blank, the backendbucket will be compatible with Global External Application Load Balancer orClassic Application Load Balancer.
LOAD_BALANCING_SCHEMEmust be one of:INTERNAL_MANAGED,EXTERNAL_MANAGED. --max-ttl=MAX_TTL- Specifies the maximum allowed TTL for cached content served by this origin.
The 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, oran Expires header more than maxTtl seconds in the future, are capped at thevalue 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 objectsmay be evicted from the cache before the defined TTL.
When creating a new backend with CACHE_ALL_STATIC and the field is unset, orwhen updating an existing backend to use these modes and the field is unset, adefault 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-]negative-caching- Negative caching allows per-status code cache TTLs to be set, in order to applyfine-grained caching for common errors or redirects. This can reduce the load onyour origin and improve the end-user experience by reducing response latency.
Negative caching applies to a set of 3xx, 4xx, and 5xx status codes that aretypically useful to cache.
Status codes not listed here cannot have their TTL explicitly set and aren'tcached, in order to avoid cache poisoning attacks.
HTTP success codes (HTTP 2xx) are handled by the values of defaultTtl andmaxTtl.
When the cache mode is set to CACHE_ALL_STATIC or USE_ORIGIN_HEADERS, thesevalues apply to responses with the specified response code that lack any
cache-controlorexpiresheaders.When the cache mode is set to FORCE_CACHE_ALL, these values apply to allresponses with the specified response code, and override any caching headers.
Cloud CDN applies the following default TTLs to these status codes:
- HTTP 300 (Multiple Choice), 301, 308 (Permanent Redirects): 10m
- HTTP 404 (Not Found), 410 (Gone), 451 (Unavailable For Legal Reasons): 120s
- HTTP 405 (Method Not Found), 421 (Misdirected Request), 501 (Not Implemented):60s
These defaults can be overridden in cdnPolicy.negativeCachingPolicy.
Use
--negative-cachingto enable and--no-negative-cachingto disable. --negative-caching-policy=[[CODE=TTL],…]- Sets a cache TTL for the specified HTTP status code.
NegativeCaching must be enabled to config the negativeCachingPolicy.
If you omit the policy and leave negativeCaching enabled, Cloud CDN's defaultcache TTLs are used.
Note that when specifying an explicit negative caching policy, make sure thatyou specify a cache TTL for all response codes that you want to cache. Cloud CDNdoesn't apply any default negative caching when a policy exists.
CODEis the HTTP status code to define a TTL against. Only HTTPstatus codes 300, 301, 308, 404, 405, 410, 421, 451, and 501 can be specified asvalues, and you cannot specify a status code more than once.TTL is the time to live (in seconds) for which to cache responses for thespecified
CODE. The maximum allowed value is 1800s (30 minutes),noting that infrequently accessed objects may be evicted from the cache beforethe defined TTL. --[no-]request-coalescing- Enables request coalescing to the backend (recommended).
Request coalescing (or collapsing) combines multiple concurrent cache fillrequests into a small number of requests to the origin. This can improveperformance by putting less load on the origin and backend infrastructure.However, coalescing adds a small amount of latency when multiple requests to thesame URL are processed, so for latency-critical applications it may not bedesirable.
Defaults to true.
Use
--request-coalescingto enable and--no-request-coalescingto disable. --resource-manager-tags=[KEY=VALUE,…]- Comma-separated list of Resource Manager tags to apply to the backend bucket.
--serve-while-stale=SERVE_WHILE_STALE- Serve existing content from the cache (if available) when revalidating contentwith the origin; this allows content to be served more quickly, and also allowscontent to continue to be served if the backend is down or reporting errors.
This setting defines the default serve-stale duration for any cached responsesthat do not specify a stale-while-revalidate directive. Stale responses thatexceed the TTL configured here will not be served without first beingrevalidated with the origin. The default limit is 86400s (1 day), which willallow stale content to be served up to this limit beyond the max-age (ors-max-age) of a cached response.
The maximum allowed value is 604800 (1 week).
Set this to zero (0) to disable serve-while-stale.
--signed-url-cache-max-age=SIGNED_URL_CACHE_MAX_AGE- The amount of time up to which the response to a signed URL request will becached in the CDN. After this time period, the Signed URL will be revalidatedbefore being served. Cloud CDN will internally act as though all responses fromthis backend had a
Cache-Control: public, max-age=[TTL]header,regardless of any existing Cache-Control header. The actual headers served inresponses will not be altered. If unspecified, the default value is 3600s.For example, specifying
12hwill cause the responses to signed URLrequests to be cached in the CDN up to 12 hours. See $gcloud topic datetimes forinformation on duration formats.This flag only affects signed URL requests.
- At most one of these can be specified:
--global- If set, the backend bucket is global.
--region=REGION- Region of the backend bucket to create. Overrides the default
compute/regionproperty value for this command invocation.
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--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 helpfor details. - NOTES
- This command is currently in beta and might change without notice. Thesevariants are also available:
gcloudcomputebackend-bucketscreategcloudalphacomputebackend-bucketscreate
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-28 UTC.