Cloud CDN not caching: cache misses because of Set-Cookie, Cache-Control or missing cache mode

Responses keep missing the CDN cache, so every request reaches the origin.

Exact message you may see Cloud CDN cache missCloud CDN not caching responsescacheStatus MISS Cloud CDNcache hit ratio low Cloud CDNCloud CDN cache-mode FORCE_CACHE_ALL
Seen on: Google Cloud HTTP

Meaning

Cloud CDN only caches cacheable responses: no Set-Cookie, no Cache-Control: private/no-store, appropriate status codes, and a cache mode that allows it (CACHE_ALL_STATIC/FORCE_CACHE_ALL). Check the Age header and cacheStatus in logs, and the cache key (cookies/headers/query strings).

Common causes

  • Set-Cookie on the response
  • Cache-Control: private or no-store
  • Cache mode USE_ORIGIN_HEADERS without headers
  • Cache key includes varying parameters
  • Response status not cacheable

⚡ Quick fix

  1. Remove Set-Cookie from cacheable responses
  2. Set Cache-Control: public, max-age=3600 or a cache mode override
  3. Trim the cache key to needed parts

Detailed fix by platform

Shell

  1. gcloud compute backend-services update BACKEND --global --enable-cdn --cache-mode=CACHE_ALL_STATIC

How to diagnose

  1. Set-Cookie — Present?
  2. Cache-Control — Public?
  3. Cache key — Minimal?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

502 Bad Gateway: failed_to_connect_to_backend — Google Cloud Load Balancing: 502 Bad Gateway — jsonPayload.statusDetails: failed_to_connect_to_backend / backend_connection_closed_before_data_sent_to_client (Google Cloud / Firebase)502 Bad Gateway: fail…cache — Firebase Hosting serves old files after deploy (CDN cache and Cache-Control headers) (Google Cloud / Firebase)cacheCache-Control — CDN not caching: Cache-Control private / no-cache / Set-Cookie on the response (HTTP)Cache-Controlcf-cache-status: DYNAMIC — Cloudflare not caching: cf-cache-status DYNAMIC / BYPASS / MISS every time (Cloudflare)cf-cache-status: DYNA…Cloud Armor — Cloud Armor returns 403 Forbidden: request blocked by a security policy rule (Google Cloud / Firebase)Cloud ArmorCSP violation — Refused to load the script because it violates the following Content Security Policy directive (JavaScript)CSP violationDomain still resolves to the old IP (DNS propagation/cache) — Networking: DNS changed but the domain still resolves to the old IP — TTL and resolver caching ("propagation") (Networking)Domain still resolves…Google-managed cert — Google-managed SSL certificate stuck in PROVISIONING / FAILED_NOT_VISIBLE on the HTTPS load balancer (Google Cloud / Firebase)Google-managed certCloud CDN

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.