What Is a CDN and How Does It Work?

A content delivery network, or CDN, uses servers in multiple locations to deliver a website's content to visitors. The origin is the server or service that stores the website's files or generates its pages. The CDN servers that handle visitor requests are called edge servers. An edge can return a stored response when caching rules allow it, or fetch content from the origin when needed. Serving a stored copy can shorten the wait for a response and reduce requests to the origin.
A CDN is often a reverse proxy for a website. Visitors contact the CDN address, while the CDN makes separate requests to the origin as needed. Seeing a CDN IP address or an apparently nearby geolocation result does not reveal where the origin server is hosted. That address may be used by CDN servers in several locations, so a location lookup cannot identify the server that handled a particular visit.
Separate the Origin from the Edge
The origin runs the application or stores the files the CDN retrieves. A CDN edge is an entry point that can respond on behalf of that origin under configured rules. For a cacheable image, the first request reaching an edge may find no stored copy, which is a cache miss. The edge fetches the image from the origin or an upstream CDN tier, stores an allowed copy, and returns it. If a later request matches a reusable stored copy, serving that response is a cache hit. The cache key is the set of request details used to identify the copy, such as the URL and any other fields included by the cache policy.
Not every response is stored. Requests for a personalized account page may need to bypass the CDN cache so the application can check the session and return the right account data. A website can therefore use a CDN while still relying on the origin to generate pages and process transactions.
Some CDN products also handle encrypted browser connections, filter traffic, or route requests between services. Those are separate features from caching. Do not assume that buying a CDN automatically enables a particular security control or eliminates the need for a healthy origin.
Follow DNS, Routing, and Cache Lookup
A site owner configures DNS and the CDN so the public hostname reaches the CDN's network. The specific edge that handles a visitor is chosen by the provider's routing and network conditions. It may be geographically close, but the nearest physical data center is not guaranteed to be the selected one. Network topology, capacity, policy, and failures can all change the path.
Once a request reaches an edge, the CDN checks whether caching is allowed and looks for a response with a matching cache key. A matching copy that may be reused without validation can be returned immediately. On a miss, the CDN forwards the request, receives a response, and may store that response for future requests. The Cache-Control response header tells caches how a response may be stored and reused. CDN settings can also affect the decision, so the application and CDN rules need to agree.
A stored response is fresh while it remains within its allowed freshness lifetime and stale after that lifetime ends. Fresh does not necessarily mean that the origin has not changed; the cache may not have checked yet. Revalidation lets the edge ask whether the stored content is still current and reuse it without downloading the body again if the origin confirms that it is unchanged. Inspect the provider's cache-status information and origin logs when diagnosing a specific request. One cache hit on one edge does not mean every edge already has the same object.
Choose What Can Be Cached
Static assets such as versioned images, stylesheets, scripts, and downloads are common cache candidates because many visitors can use identical bytes. Give these files suitable cache lifetimes and use a new filename or versioned URL when their content changes if long caching is intended. HTML can also be cached when it is the same for the audience and the site's update process can manage freshness.
Dynamic content needs a more careful decision. A public article page generated on demand may still be cacheable for a short period. A CDN normally uses a shared cache, meaning that a stored response can serve multiple visitors. Keep private account data out of that shared storage unless the application has a tested way to isolate each user's content. Check how cookies and authorization affect both storage and access instead of enabling a rule that caches every response. The wrong cache key can reveal one visitor's content to another.
CDNs may cache different representations for device, language, encoding, or other request dimensions. The cache key must distinguish requests that need different responses. Unnecessary differences split reusable content into extra entries, while missing a relevant difference can send the wrong version to a visitor. Test representative requests with their real headers and user states before expanding a cache rule.
Understand the Limits of a CDN
An edge cache can reduce repeated fetches, but it cannot fix a slow database query on a cache miss. An edge with no usable copy must fetch one from the origin or another cache. A stale copy may still be served if the applicable cache rules allow it; expiration alone does not mean the stored data was deleted. Latency also includes DNS, connection setup, page rendering, and third-party resources. Measure the complete visitor experience rather than assuming that a CDN always makes every page faster.
Distributed delivery can improve resilience for some failures, yet it does not guarantee an outage-free site. A CDN itself can have incidents, routing changes, or configuration errors. If an origin is unavailable, only content that remains usable under the cache policy may still be served, and a dynamic transaction can fail. Plan monitoring for both edge and origin health.
A CDN also does not replace all hosting requirements. The site still needs an application or content source, a secure connection to the origin, certificate management where applicable, and a process for changes. Check which parts of hosting, certificate renewal, and content updates the CDN provider manages and which you must manage yourself.
Check What Visitors Actually Receive
When a visitor sees an old page, identify whether that version came from the browser cache, a CDN edge, an upstream cache, or the origin. Check response headers and the content version at each layer before clearing content. A purge can remove a cached copy, but if the origin still serves the old version, the edge may fetch it again. Check the CDN provider's purge behavior before relying on a change to appear everywhere at once.
With anycast, several CDN locations can announce the same IP address, and network routing selects which location receives a request. An IP geolocation database may assign one location to that shared address even though visitors reach different servers. To investigate a particular request, compare the CDN location recorded for that request with the configured origin and its logs.
Compare response times and origin request counts for the pages and files visitors actually use. Test both the first request to an empty cache and later requests to a populated cache, and include signed-in and signed-out visits. Check that each response contains the intended content: faster delivery is not an improvement if the CDN serves the wrong page or an outdated file.







