CDN for APIs

Set an explicit cache key and lifetime for public, read-only API responses. Bypass authentication-sensitive requests and forward writes to the application.

Example cache policy
Public, cacheable resource
GET /v1/public/catalogue
Bypass shared cache
GET /v1/accounts/me

Identify public responses that can share a cache

Cache safe GET responses at Cloud CDN with explicit TTLs. Bypass authenticated, mutation and user-specific APIs. Use Origin Shield and TLS at the edge.

Shared public GET responses

The edge can reuse a public JSON response when the request matches its cache key and the response is still fresh.

Origin Shield for thundering herds

When TTLs expire, edges do not all hit the API origin at once.

Mutations stay on the API

POST, PATCH, PUT and DELETE bypass cache. Tokens can protect private GETs.

Configuration

Cloud CDN overview
  1. Put Cloud CDN in front of the API hostname

    Pull the existing API origin over HTTPS.

  2. Mark cacheable GET paths

    Set TTLs for public catalogue, config or content endpoints.

  3. Bypass private and mutation routes

    Authenticated JSON and writes must reach the application.

  4. Purge when data changes

    Invalidate API paths from the publish or deploy pipeline.

Operational outcomes

  • Public API GETs can be cached globally
  • Writes remain origin-dynamic
  • Origin Shield protects API clusters
  • Private GETs can require a token

Frequently asked questions

Can I cache GraphQL?

Only when the query is public and identical. Most GraphQL POSTs should bypass cache or use persisted GET queries you control.

What about Authorization headers?

Responses that vary on Authorization should not be cached as public. Bypass or use a carefully designed cache key.

Does this replace an API gateway?

No. Cloud CDN is a delivery and cache layer. AuthZ, rate limits and routing at the gateway remain in place.

Can WebSockets share the hostname?

Yes. WebSocket upgrades bypass cache. See CDN for WebSockets.