What Is a CDN? Use Cache Policy to Improve Delivery and Limit Origin Load
Learn how edge caches serve repeated requests, how cache keys and freshness work, and what to check for privacy, stale content, performance, and cost.
What Is a CDN? Use Cache Policy to Improve Delivery and Limit Origin Load
A content delivery network (CDN) stores cacheable responses on distributed edge servers between users and origin servers, so later requests can be served from a location closer to the user. A cache hit can avoid a round trip to the origin and reduce latency and origin traffic. The first request, or content missing from cache, still has to come from the origin. A CDN does not make every request fast or replace the origin server.
How does a CDN deliver a request?
An origin is the server or storage that first provides an image, script, page, or other resource. When a user requests a URL, DNS and CDN routing direct the request to a suitable edge location. The edge checks whether the requested content is stored and still fresh.
**Cache hit:** The edge has a valid response and sends it directly to the user. The origin does not need to handle that request.
**Cache miss:** The edge has no valid response, so the CDN forwards the request to the origin. It returns the response to the user and stores it if the policy allows.
**Revalidation:** After a cached response becomes stale, the CDN may ask the origin whether it changed or fetch a new response. Some products can route through a regional cache.
For example, many users may request the same logo. The first request might be fetched from the origin; later eligible requests may be served from the edge. This requires the response to be cacheable and the requests to share a cache key. A cache key usually uses parts of a URL to distinguish requests. If irrelevant tracking query strings are included, identical files can split across multiple cache entries and reduce the hit ratio.
Why treat static and personalized responses differently?
Static assets that can be shared across users, such as versioned images, CSS, and JavaScript, are often good candidates for a CDN cache. Account pages or responses that vary by logged-in user or permission can expose one user's information to another if shared incorrectly. Caching user-specific responses requires careful design of authentication, cookies, headers, cache keys, and policy. If you cannot verify safe separation, avoid storing them in a shared cache.
A CDN may pass dynamic requests to the origin without caching. Routing or connection features may still help, but do not expect the same benefit as caching static content. Cacheability and default behavior vary by CDN product, origin response headers, and configuration rules.
How do you control freshness and updates?
An origin server can use HTTP Cache-Control response headers to tell browsers and shared caches how long to keep a response. max-age sets freshness for general caches; s-maxage can specify a separate freshness period for shared caches such as a CDN. no-cache can allow storage but require validation with the origin before reuse; no-store tells caches not to store the response. Details vary by provider, so check the CDN's documentation and actual rules.
A longer TTL (time to live) can make repeat requests more likely to use cache and reduce origin load, but an old copy may remain after content changes. A very short TTL can cause frequent revalidation and origin requests. When publishing a new file version, putting the version in the URL creates a new cache entry and makes the change explicit. If the URL must stay the same, a CDN's invalidation feature can remove existing entries; confirm propagation time and request limits for that service.
How should you evaluate a CDN?
Cache hit ratio and origin requests: Check what share of requests the cache serves. A low ratio can mean content is not cacheable, query strings split cache keys, or users request many different resources. A high ratio alone does not prove that user-specific responses are isolated safely.
User-perceived latency: Measure representative requests by user region, DNS routing, content type, distance to origin, and cache state. Improvement may be limited when the edge has no cached copy or dynamic responses depend on the origin.
Origin load and cost: A CDN can reduce origin requests and transfers, but can add charges for CDN requests, egress, invalidation, logs, and filling the cache from the origin. Compare hits and misses, retention, and traffic regions.
Correctness and privacy: Review Cache-Control, Vary, authorization, cookies, and cache keys so responses from different requests are not mixed. Add explicit rules to keep account-specific or personal data out of shared caches, then verify that a new version appears after deployment.
A CDN can help serve frequently requested static content from a closer cache and reduce load on the origin. Its benefit depends on cacheability, keys and TTL, content update strategy, user location, and cost. Separate safely shareable assets from personalized responses, validate the policy on one path, and expand from there.
References
[How Amazon CloudFront delivers content](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/HowCloudFrontWorks.html)
[Cloudflare origin Cache-Control behavior](https://developers.cloudflare.com/cache/concepts/cache-control/)
[Google Cloud CDN overview and hit/miss behavior](https://docs.cloud.google.com/cdn/docs/overview?hl=en)
[Google Cloud CDN caching overview](https://docs.cloud.google.com/cdn/docs/caching)
[Google Cloud CDN content delivery best practices](https://docs.cloud.google.com/cdn/docs/best-practices)