DNS and CDN delivery
Follow a request from name to content
DNS (Domain Name System) resolves a name to records that help a client find a service. A CDN (content delivery network) can serve reusable responses from an edge cache nearer to the client. The two systems solve different problems. DNS does not deliver the page, and a CDN does not replace authoritative DNS.
Imagine a bookstore at shop.example.com. A browser asks its recursive resolver for the address. On a cache miss the resolver follows DNS delegation to an authoritative server. It returns an illustrative address, 192.0.2.10, for the edge service. The browser connects to the edge using HTTPS and requests /covers/book-7.webp. If the edge already has a fresh permitted response, it returns it; otherwise it contacts the origin, the service that supplies the original content. All names, addresses and times here are fictional offline fixtures; do not make real requests.
Zones, records and DNS caching
A DNS zone is an administered portion of the name hierarchy. NS records identify authoritative name servers; SOA provides zone administration information. A and AAAA records contain IPv4 and IPv6 addresses. CNAME points to another name rather than directly to an address. MX identifies mail exchangers, and TXT carries text used by mechanisms such as domain verification. A conventional CNAME cannot coexist with other ordinary records at the same owner name; zone apexes already need SOA and NS. Provider-specific alias mechanisms can address some apex use cases; verify target and record restrictions.
TTL (time to live) is expressed in seconds for DNS records. In a toy resolver, an A answer received at t=0 with TTL 60 remains fresh through t=59. If the authoritative value changes at t=20, the resolver may continue returning the old address until t=60. A fresh lookup can then obtain the new value. Lower a TTL sufficiently before a planned change if appropriate, not just at the instant of migration. Negative responses may also be cached; actual resolver policies and existing connections complicate exact cutover timing.
Compare managed DNS and traffic steering
AWS Route 53 hosts zones and supports routing policies including weighted and failover routing with eligible health checks. Azure DNS hosts zones; Azure Traffic Manager is a separate DNS-based traffic steering service. Google Cloud DNS offers public and private managed zones and routing policies with health checks for supported configurations. Private zones depend on network visibility and resolver configuration. They are not access controls for the destination service.
A DNS routing policy selects an answer; it does not proxy each HTTP request. A health check is a periodic observation, not proof that every client request will succeed. If a primary is marked unhealthy at t=20, a resolver with the earlier 60-second TTL may still send users to it until expiry. Weighted DNS answers also need not produce an exact percentage of individual HTTP requests because many clients reuse resolver answers or connections. Inspect health conditions, cached answers and actual traffic separately.
CDN, reverse proxy and load balancer
A reverse proxy accepts requests on behalf of an upstream service; a load balancer distributes traffic among eligible backends. A CDN emphasizes geographically distributed delivery and caching. Products may combine these functions. Amazon CloudFront, Azure Front Door and Google Cloud CDN are representative edge delivery offerings, not interchangeable APIs. Google Cloud CDN works with supported external Application Load Balancer configurations; Azure Front Door integrates global web routing and optional caching. Use a simple reverse proxy or regional load balancer when global caching is unnecessary.
In the bookstore, static covers can use an edge cache, while inventory and checkout requests reach application servers. A cache miss is not an error: it often means the requested representation must be fetched. A cache hit is not proof the origin is currently healthy.
Cache keys, freshness and releases
A cache key identifies which stored response may be reused. It commonly includes a path and relevant host, query or request-header dimensions; exact fields depend on the product and policy. Suppose /cover.webp?size=small and /cover.webp?size=large return different images. Excluding size from the key would allow the wrong variant to be reused. Including irrelevant tracking parameters can fragment a cache. Only omit a dimension after confirming that it cannot change the response, its authorization or representation.
HTTP freshness is separate from DNS TTL. For a public cover, Cache-Control: public, max-age=120 allows ordinary caches to consider the response fresh for the specified age, subject to applicable policy. s-maxage can specify shared-cache freshness; no-cache normally requires validation before reuse, not a ban on storing; private restricts shared caching; no-store forbids ordinary storage. A stale representation may be revalidated using an ETag and If-None-Match; a 304 response can let a cache reuse its stored body. Some provider settings override origin directives, so test effective behavior. Use versioned asset paths, such as /covers/book-7.v2.webp, and reviewed invalidations for urgent corrections. A CDN purge is not a DNS change and need not clear browser caches.
Measure the benefit and troubleshoot
In a toy cache with 1,000 eligible requests, 800 fresh hits and 200 misses, request hit ratio is 80%. Assuming one origin fetch per miss and equally sized 100 KiB responses, origin transfer is 20,000 KiB instead of 100,000 KiB. Real origins can see revalidations, retries and range requests; byte hit ratio can differ from request hit ratio. An illustrative bill includes edge requests, delivery bytes, origin transfer and any invalidation or other service fees; compare current provider units before deployment.
For an incorrect page, first inspect DNS from the affected resolver, then certificate and HTTP status, cache age/key and origin version. A fresh DNS answer does not imply fresh HTML. Compare a versioned public asset against a known origin fixture and inspect synthetic cache logs. Do not clear all caches or change public DNS as a first response. Practice: predict what changes at t=60 for DNS versus an independently filled cache with freshness 120 seconds.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
DNS and CDN delivery — knowledge check
Choose the best answer for each offline scenario.
A resolver caches an address at t=0 for 60 seconds. The authoritative address changes at t=20. In the toy resolver, what happens at t=30?
What does DNS-based health routing directly select?
Two image sizes share a path and differ by size query value. What should the key preserve?
What does HTTP no-cache ordinarily require before reuse?
Of 1,000 eligible requests, 800 are fresh hits. What is the request hit ratio?