Skip to content
LatchkeyLatchkey home

Self-Healing CI: Recovering a CDN Cold Cache 504

A 504 from a CDN on the first request to an uncached path is a slow origin fetch, not a broken asset -- once the edge has warmed the object, the same request succeeds.

The problem

A post-deploy check fails with a 504 Gateway Timeout from the CDN because the requested path was not cached and the edge’s origin fetch was slow on the first hit. The asset and origin are fine; the cold-cache fetch took too long once. A human re-runs and, with the object now warm at the edge, the request returns 200 unchanged.

Typical symptom
HTTP/1.1 504 Gateway Timeout
# first request to an uncached path; edge origin-fetch timed out, then warms the cache

Why it happens

On a cache miss the CDN edge fetches the object from origin before serving it, and that first cold fetch can be slow enough to time out as a 504, even though the asset and origin are healthy and every subsequent request is served fast from the warm edge.

It is a cold-cache origin-fetch blip, not a broken asset: once the edge has the object cached, the same request succeeds, so a retry returns 200.

The manual fix

Manual mitigations for a cold-cache 504:

  1. Re-run the check after the edge has warmed the object.
  2. Pre-warm critical paths after deploy so the first real request is not a cold miss.
  3. Add retry-with-backoff around post-deploy checks that hit the CDN.

How this gets automated

A cold-cache 504 is distinguishable from a real origin outage by whether the request recovers once the edge warms the object. A self-healing CI pipeline detects the gateway-timeout-on-cold-cache condition, retries after the edge warms, and only escalates if the request keeps timing out, which is the real signal of a genuine origin problem rather than a cold fetch.

Frequently asked questions

What causes Self-Healing CI: recovering a CDN cold cache 504?
A post-deploy check fails with a 504 Gateway Timeout from the CDN because the requested path was not cached and the edge’s origin fetch was slow on the first hit. The asset and origin are fine; the cold-cache fetch took too long once. A human re-runs and, with the object now warm at the edge, the request returns 200 unchanged.
How do I fix Self-Healing CI: recovering a CDN cold cache 504 manually?
[object Object]
Can Self-Healing CI: recovering a CDN cold cache 504 be fixed automatically?
A cold-cache 504 is distinguishable from a real origin outage by whether the request recovers once the edge warms the object. A self-healing CI pipeline detects the gateway-timeout-on-cold-cache condition, retries after the edge warms, and only escalates if the request keeps timing out, which is the real signal of a genuine origin

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card