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

**Code:** `Cloud CDN` · **Category:** Google Cloud / Firebase · **Seen on:** Google Cloud, HTTP

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/gcp/cloud-cdn-cache-miss-set-cookie-vary)
