How Cloud CDN Caches Content: Cache Modes, Cache-Control and Cache Keys

GCP Study Hub
November 10, 2026

Cloud CDN caches content at Google's edge for a global external Application Load Balancer. It plugs straight into that load balancer, and its origin is either a backend service or a Cloud Storage backend bucket. What it stores, and for how long, depends on the Cache-Control header the origin returns, the cache mode, and the cache key it builds for each request. An external passthrough Network Load Balancer works at layer 4 and does not support Cloud CDN, so any design that needs edge caching starts with the global external Application Load Balancer. For the Professional Cloud Network Engineer exam, the useful skills are reading why content is or is not being cached and knowing which setting actually changes that.

Cache-Control and the default cache mode

Cloud CDN respects the Cache-Control header that the origin returns. An object can carry a max-age that sets how long edge caches keep it.

The default cache mode is CACHE_ALL_STATIC. In this mode, Cloud CDN never stores a response marked private, even when its content type would normally count as static. The private directive works per response, so it applies only to the content that carries it.

Cache-Control with a Cloud Storage origin

When the origin is a Cloud Storage bucket, Cloud Storage returns the Cache-Control value saved in each object's metadata. The setting affects only that object, so different files in the same bucket can be cached differently.

Object metadata does not carry over between uploads. Each upload creates a new object with its own metadata, so a header set by hand on one copy disappears when the file is replaced. Any Cache-Control value a file depends on has to be set as part of every upload of that file.

Settings on the bucket itself, such as lifecycle rules and public access controls, govern the stored objects and who can read them. They do not decide what Cloud CDN keeps at the edge. Restricting public access to a cached object leaves anonymous visitors with an access error rather than a fresh copy.

Compression and encoding

Cloud CDN passes along and caches whatever encoding the backend returns. Leaving Cloud CDN's dynamic compression off does not make it strip compression that the origin already applied, so the encoding stored at the edge reflects what the backend sent.

TTLs and negative caching

The default and maximum TTLs control how long cached content stays fresh. Setting both to zero makes content stale right away, which lowers the cache hit ratio. Negative caching is a separate control that applies only to how error responses, such as 404s, are cached.

How cache keys work

Every cached object is stored under a cache key. By default, Cloud CDN builds the cache key for a backend service from the full request URI, which includes the protocol and the hostname. The same file requested through several hostnames over both HTTP and HTTPS therefore becomes a separate cache entry for each hostname and protocol combination. Each entry is filled from the origin on its own, which keeps the hit ratio low even though the content is identical.

Updating the cache key policy on the backend service so that host and protocol are excluded maps all of those requests to a single cache entry. The first request fills the cache, and later requests from any of the hostnames or protocols become hits. The change is made on the load balancer's backend service.

Versioned URLs are a different tool. They push out new content without waiting for cached copies to expire, and every distinct URL is its own cache entry. For the Professional Cloud Network Engineer exam, we would keep these controls separate: the cache key decides how many entries one piece of content occupies, while Cache-Control and TTLs decide whether and for how long each entry is kept.

Our Professional Cloud Network Engineer practice exams cover how Cloud CDN caches content alongside cache invalidation and the global external Application Load Balancer, with detailed explanations that drill these distinctions.

Get tips and updates from GCP Study Hub

arrow