The site name points at the CDN A user in Seoul opens https://www.example.com/app.3f9a.js. The site owner set www.example.com as a CNAME (or alias) to a hostname the CDN gave them, for example on CloudFront, Cloud CDN or Cloudflare.
So the DNS answer does not come from your servers. It comes from the CDN's name servers.
The user reaches a nearby edge, and TLS ends there Some CDNs answer DNS with the address of an edge near the user (GeoDNS). Others use anycast: the same IP is announced from every location, and internet routing carries the packets to a nearby one.
The edge holds your certificate and finishes the TLS handshake close to the user. This alone cuts round trips, even before any caching.
Key idea Run dig on your site name. A CNAME to the CDN's hostname shows the CDN is in front.
Cache miss: the edge fetches from the origin The edge builds a cache key from the request. By default this is usually the host and path, often with the query string. You can add or drop query strings, headers or cookies in the CDN settings.
Nothing is stored under that key yet, so it is a MISS. The edge asks the origin shield, which also misses, and the request goes on to the origin: an object storage bucket or a load balancer in front of your servers.
The origin says how long the copy may be kept The origin answers 200 with Cache-Control: public, max-age=31536000, immutable. max-age is the freshness time in seconds for any cache, including the browser.
s-maxage applies only to shared caches such as a CDN and overrides max-age there. Many CDNs also let you set a default or override TTL in their own settings. The edge stores the response and passes it on.
Key idea If the origin sends no Cache-Control, the CDN falls back to its own default TTL. Set the header on purpose rather than relying on that default.
Cache hit: the next user never reaches the origin A minute later another user nearby asks for the same file. The key matches a fresh entry, so it is a HIT. The edge answers from the cache, and the origin sees nothing.
The Age header shows how many seconds the copy has been in a cache. Many CDNs add their own header too, such as X-Cache: Hit from cloudfront or cf-cache-status: HIT.
An expired copy is checked with ETag, not downloaded again The HTML page /index.html has max-age=60. After 60 seconds the stored copy is stale. The edge does not throw it away. It sends a conditional request with If-None-Match and the stored ETag.
If the file has not changed, the origin answers 304 Not Modified with no body. The edge marks its copy fresh again and serves it. Only headers crossed the network.
After a deploy, users still get the old file You deploy a new app.js under the same name. Edges keep serving the old copy until its TTL runs out, and browsers that cached it keep it too. Some users see the new HTML with the old script, and the page breaks.
A purge (invalidation) tells the CDN to drop paths. It can take a while to reach every edge, some CDNs charge for many paths, and it does not clear browser caches.
Watch out Put a content hash in static file names (app.3f9a.js) and cache them for a year. Give the HTML a short TTL. A deploy then just points to new names, and nothing needs purging.
A personal page cached at the edge leaks to other users The page /account shows the signed-in user's name. If it is cached with a key that ignores the session cookie, the next user gets someone else's page. This is one of the worst CDN mistakes.
Send Cache-Control: private (only the browser may store it) or no-store (nobody may). Many CDNs skip responses with Set-Cookie by default, but behavior differs between vendors, so do not rely on it.
Watch out Mark every personalized or authenticated response private or no-store at the origin, and check the CDN does not override it with a "cache everything" rule.
An origin shield collapses misses, and the origin only trusts the CDN With hundreds of edges, each one missing on its own would hit the origin hundreds of times. An origin shield is one regional cache layer between edges and origin. Edge misses go there first, so the origin sees roughly one request per object.
Lock the origin so users cannot skip the CDN. A bucket can allow reads only from the CDN (for example CloudFront origin access control). A load balancer can accept only the CDN's IP ranges or a secret header.
Headers decide everything a CDN does DNS or anycast sends the user to a nearby edge, which ends TLS. The edge looks up the cache key. On a hit it answers at once. On a miss it goes through the shield to the origin and stores the answer for as long as Cache-Control allows.
Stale copies are revalidated with ETag and 304. Hashed file names make deploys safe without purging, and private or no-store keeps personal pages out of the shared cache.
Summary Read the response headers first: Cache-Control, Age, ETag and the CDN's hit header tell you what the cache did and why.