Skip to main content

Cloud CDN

Exam guide§2.3

Cloud CDN (Content Delivery Network) uses Google's globally distributed edge points of presence to cache HTTP(S) load-balanced content close to your users. It is enabled with a single checkbox on the backend service of an external Application Load Balancer, giving faster delivery while reducing serving costs.

NumbersEdge cache sites
  • 90+ cache sites (edge points of presence) spread across metropolitan areas.
  • Regions covered: Asia Pacific, Americas, and EMEA.
  • The authoritative, up-to-date list lives in the Cloud CDN documentation.

Response flow

User in San FranciscoUser in Los AngelesUser in New YorkCloud CDNApplication Load BalancerMonitoring and Loggingus-central1Frontend Autoscalingasia-east1Frontend Autoscalingus-east1Cloud Storage
A user in San Francisco is served straight from the Cloud CDN edge (blue). A cache miss is forwarded to the Application Load Balancer, which routes to a regional instance group or the Cloud Storage bucket; the response can then be cached at the edge and is logged in Monitoring and Logging.

A URL map on the load balancer decides which backend serves the content - for example, a Cloud Storage bucket for static content and instance groups for PHP traffic.

  • Cache miss: the first user in San Francisco requests content the local cache site cannot fulfill. The cache may pull it from a nearby cache (say, one that already served a Los Angeles user); otherwise the request is forwarded to the Application Load Balancer, which routes it to a backend (the us-central1 instance group or the us-east1 bucket).
  • Cache hit: if the backend response is cacheable, the San Francisco cache site stores it. A later request for the same content is served from the edge, shortening the round-trip time and sparing the origin from processing the request.
GotchaA cache miss can still be filled by a peer edge, not just the origin

Before forwarding to the load balancer, a cache site may fetch the content from a nearby cache site that already has it. The origin backend is only contacted when no edge cache can serve the request.

Every Cloud CDN request is automatically logged in Google Cloud; each log entry records a Cache Hit or Cache Miss status for the load balancer's HTTP request.

Cache modes

Cache modes control the factors that determine whether Cloud CDN caches your content - whether it respects the origin's cache directives, and how cache TTLs are applied. Cloud CDN offers three:

More aggressive caching, less origin controlRespects originUSE_ORIGIN_HEADERSCaches only responses whose origin setsvalid cache directives and caching headers.Static by defaultCACHE_ALL_STATICAuto-caches static content lacking no-store /private / no-cache; also caches valid directives.Ignores originFORCE_CACHE_ALLUnconditionally caches all responses,overriding any origin cache directives.
The three cache modes ordered by how much the origin controls caching: USE_ORIGIN_HEADERS defers entirely to the origin, CACHE_ALL_STATIC caches static content by default, and FORCE_CACHE_ALL overrides the origin and caches everything.
GotchaFORCE_CACHE_ALL can leak per-user content on a shared backend

Because FORCE_CACHE_ALL ignores origin directives, do not use it on a shared backend that serves private, per-user content (dynamic HTML, API responses) - it would cache and re-serve one user's private response to others.

0%0 of 147 pages studied