Caching with Cloud Storage built-in cache

This page discusses the options you have to control how yourCloud Storage objects are cached. This page focuses on theCloud Storage built-in cache andCloud CDN, butCloud Storage is also compatible with third-party Content DeliveryNetworks (CDNs).

Overview

Control caching for your Cloud Storage objects to enhance applicationperformance and help maintain content freshness. Caching object data storescopies of the data in Google or internet caches, which accelerates future dataread requests. Cloud Storage offers built-in caching that behaves likea CDN. You manage this built-in caching through theCache-Controlmetadata, which defines how and for how long caches store your objects.

For more advanced control,use Cloud Storage caching with Cloud CDN orexplore Anywhere Cache.

Caching with Anywhere Cache

Anywhere Cache provides a fully-managed, always consistent SSD-backedzonal read cache that can be created in the same zones as your workloads incompute. The caches are used to accelerate serving data forlarge, data-intensive workloads. Data that's read from a cache is chargedreduced data transfer fees compared to data that's read directly frommulti-region buckets, letting you optimize costs.

For more information, seeAnywhere Cache.

Built-in caching for Cloud Storage

Cloud Storage can behave like a Content Delivery Network (CDN) with nowork on your part, because an object's data is cached in theCloud Storage network if itsCache-Control metadata is set toallow caching and the following criteria are met:

Important: Proxies or browsers might cache object data and subsequently serveobject data from their cache based solely on the object'sCache-Controlmetadata. Additionally, depending on the network path, once object data has leftCloud Storage, theCache-Control value associated with it might beoverwritten, for example by a CDN that the data passes through.

Cloud Storage respectsstandard values forCache-Control, such as the following:

  • public: the object can be cached.

  • private: the object won't be cached by Cloud Storage, but can becached in a requester's local cache.

  • no-cache: the object can be cached, but cannot be used to satisfy futurerequests unless first validated by Cloud Storage.

  • no-store: the object can't be cached.

  • max-age=TIME_IN_SECONDS: the length of time an objectcan be cached before it's considered stale. You can setmax-age to anylength of time. Stale objects are not served from caches, except inspecial circumstances.

To set theCache-Control metadata for an object, seeEditing object metadata.

Built-in caching behavior with IAM Deny policies

When there's an organization-level IAM Deny policy thatrestricts read access for an object from theprincipal identifierallUsers,built-in caching is disabled for the object, even if there's a bucket-levelIAM policy that grants read access for the object toallUsers.However, if the IAM Deny policy only restricts individual users,built-in caching remains enabled for the object.

Performance considerations

Performance can be much better for publicly cacheable objects. If you have anobject being used to control many clients and thus want to disable cachingto provide the latest data:

  • Consider instead setting the object'sCache-Control metadata topublicwithmax-age of 15-60 seconds. Most applications can tolerate having anobject be out of date for a few seconds, in exchange for performanceimprovements.

  • UseCache-Control: no-store for an object to indicate that the objectmust not be cached for subsequent requests in any cache.

Cloud Storage with Cloud CDN

For the best performance when delivering content to users, we recommend usingCloud Storage withCloud CDN. Compared to the cachingcapabilities you get with Cloud Storage alone, Cloud CDNoffers enhanced performance, larger cacheable file sizes, and features likecache invalidation.

To use Cloud CDN, you must use anexternal Application Load Balancer with yourCloud Storage buckets as a backend. For a tutorial on setting up anHTTP(S) load balancer with a Cloud Storage bucket, seeHosting a static website.

Cloud CDN cache modes allow you to apply a unified cachingconfiguration across all your objects. Cloud CDN uses theCache-Control metadata set on your objects to determinehow they should be cached, unless you override theCache-Controlmetadata using a cache mode orTTL limit.

Consider the differences in capabilities and pricing implications whenchoosing between Cloud Storage built-in caching and Cloud CDN:

Differences in capabilities

FeatureCloud StorageCloud CDN
Max cacheable file size10 MiB100 GiB1
Default cache expiration1 hour1 hour (configurable)
Support for custom domains over HTTPSNoYes
Cache invalidationNoYes

1The maximum cacheable file size for Cloud CDN is 100 GiBif the origin server supports byte range requests. If the origin server doesn'tsupport byte range requests, the maximum cacheable file size forCloud CDN is 10 MiB.

Pricing considerations

In terms of pricing, the choice between Cloud Storage built-in cachingand Cloud CDN depends on how much data you serve every month, whichdetermines the amount of networking costs you incur.

  • If you serve less than a few GiB of cacheable data a month, it may be cheaperoverall for you to rely on Cloud Storage built-in caching.Cloud Storage caching may incur higher networking costs thanCloud CDN, since cached and uncached objects are charged the sameoutbound data transfer cost (which means you pay full price for cache hits).However, you only pay for data storage and operations usage costs associatedwith Cloud Storage, instead of the combination ofCloud Storage, Cloud CDN, and Cloud Load Balancing.

  • If you regularly serve 100 GiB or more of cacheable data a month, or need touse per-request logging and custom headers, it may be cheaper overall for youto rely on Cloud CDN. You incur Cloud Storage outbound datatransfer and Cloud CDN cache fill costs for cache fill, andCloud CDN networking prices apply after the cache is full. Thenetworking cost savings you gain from using Cloud CDN may be worththe higher operating costs associated with maintaining the external Application Load Balancer andCloud CDN along with Cloud Storage.

What's next

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 2026-02-18 UTC.