CLOUD CONCEPT

Content Delivery Networks

Content delivery networks are geographically distributed systems that deliver content through edge locations near users, often caching responses to reduce latency and origin traffic.

Cloud Concepts Hub →

What is Content Delivery Networks

A content delivery network (CDN) sits between clients and an origin, such as object storage or an application server, and serves reusable content from distributed caches. Engineers use CDNs to improve response times, absorb traffic spikes, and potentially reduce total delivery costs, while balancing cache freshness, security, and pricing.

A content delivery network distributes content through edge locations positioned close to users in network terms. The origin remains the authoritative source, while the CDN acts as an intermediary. When a request reaches an edge cache, a cache hit returns a stored response without retrieving the complete object from the origin. A cache miss normally requires an origin fetch, and the returned response may be cached according to configured policies and HTTP headers.

In cloud architectures, a CDN commonly fronts object storage containing images, scripts, stylesheets, software downloads, or video segments. It can also front a load balancer or application endpoint. Different URL paths can use different origins and caching rules: a retail site might cache product images for a year, product descriptions for a few minutes, and bypass shared caching for checkout responses. Dynamic traffic can still benefit from edge connection handling and optimized network paths, but those benefits are distinct from caching.

The strategic cost question is whether edge delivery savings exceed the CDN's additional charges. Evaluate request volume, response sizes, geographic distribution, cache hit ratio, origin request costs, origin compute load, and applicable data-transfer rates. Include CDN request and delivery charges, logging, invalidations, and optional processing or security features. A popular download requested repeatedly across several continents is a strong candidate. A low-volume application serving unique responses to users near its origin may gain little from caching.

Effective caching depends on the cache key: the request attributes that identify a reusable response. Paths, selected query parameters, headers, and cookies may distinguish variants. Including unnecessary tracking parameters or session cookies fragments the cache and increases origin traffic. Excluding an attribute that actually changes the response can return incorrect content or expose one user's data to another. Forwarding an attribute to the origin and including it in the cache key are related but distinct configuration decisions.

Freshness is controlled through expiration rules, including time to live (TTL), and directives such as Cache-Control, subject to the CDN's policies. Longer lifetimes generally improve reuse but increase the chance of serving outdated content. Versioned filenames, such as app.a1b2.js, allow long-lived caching while deployments reference a new URL. Invalidations remove cached objects before their normal expiration, but propagation takes time and charges may apply. A cached object may also be evicted before its TTL expires; the TTL is not a guarantee of residency.

Security must cover both delivery and origin access. Use HTTPS, prevent unintended direct access to private origins, and use mechanisms such as signed URLs or signed cookies when distributing restricted content. Authorization and cache policies must work together; a CDN does not make arbitrary personalized responses safe to share. A CDN also does not replace durable origin storage, backups, or a complete disaster-recovery design.

For example, a global documentation site can keep static assets in object storage and serve them through a CDN rather than operating application servers in every region. Track cache hit ratio, origin bytes, error rates, user latency, and total cost before and after deployment. Distinguish request hit ratio from byte hit ratio: caching many tiny files may save fewer transferred bytes than caching a few popular large downloads. For architecture questions, favor CDN caching when repeated delivery, geographic reach, and origin offload are explicit needs, rather than assuming that any edge service automatically lowers costs.

Key aspects of Content Delivery Networks

CDN design balances edge proximity, cache reuse, response correctness, freshness, security, and total delivery cost.

Distributed edge delivery

Edge locations serve users closer to their network location than a centralized origin often can. This can reduce latency without requiring a full application deployment in every region.

Cache reuse and origin offload

Cache hits avoid repeated origin retrievals, reducing origin requests, transferred bytes, and application work. Benefits depend on reuse within individual caches, not simply total traffic volume.

Cache-key correctness

Include request attributes that change the response, while excluding irrelevant variations. An overly specific key wastes cache capacity; an insufficiently specific key can serve incorrect or sensitive content.

Freshness and update control

Choose TTLs according to how long stale content is acceptable. Use versioned asset URLs for predictable deployments and invalidations when existing URLs must stop serving cached content.

Whole-path cost evaluation

Compare CDN charges with avoided origin requests, compute, and data transfer. Include geographic rates, request sizes, cache misses, and optional feature charges rather than assuming a CDN is always cheaper.

Secure content and origin access

Protect viewer connections and restrict origin access where supported. Keep authorization behavior consistent with caching rules, especially for restricted downloads and user-specific responses.

Cloud services for Content Delivery Networks

In a common AWS architecture, Amazon CloudFront provides the edge delivery layer, Amazon S3 stores static assets, and an Application Load Balancer fronts application-generated responses. Path-based behaviors can direct asset requests to S3 and application requests to the load balancer, with different caching policies for each. AWS WAF can filter viewer requests at the CloudFront distribution. Restrict origin access where appropriate, keep private responses out of shared caches, and measure the combined cost of CDN delivery, origin requests, data transfer, and application capacity. Other providers offer comparable CDN patterns, although cache controls, origin security mechanisms, and billing rules differ.

Amazon CloudFront image Amazon CloudFront

Amazon CloudFront implements CDN delivery using distributed edge locations and configurable caching behavior. It can front object storage and HTTP application origins, with cache policies, signed URLs or cookies, and invalidation controls.

Open Amazon CloudFront →
Amazon Simple Storage Service image Amazon S3

Amazon S3 commonly stores static objects that a CDN retrieves on cache misses. With CloudFront, origin access control can authorize access to a private S3 bucket origin without making the objects publicly accessible.

Open Amazon S3 →
AWS WAF image AWS WAF

AWS WAF can inspect and filter viewer requests through an association with a CloudFront distribution. It complements CDN delivery with application-layer request controls but does not replace correct cache keys, authorization, or origin protection.

Open AWS WAF →