What is a CDN?

BY TOOLS.FUN  ·  MARCH 28, 2026  ·  6 min read

A Content Delivery Network (CDN) is a globally distributed network of servers that caches and delivers content from locations close to users. By serving assets from an edge server 50ms away instead of an origin server 200ms away, CDNs dramatically improve load times, reduce origin server load, and increase availability.

How CDNs Work

When a user requests a resource, the CDN routes the request to the nearest edge server (point of presence, or PoP). If the edge has a cached copy, it serves it directly — a cache hit. If not, the edge fetches it from the origin server, caches it, and serves it to the user — a cache miss. Subsequent requests for the same resource from nearby users are served from the cache. The result is lower latency, reduced bandwidth costs, and less load on your origin.

What to Cache

Static assets are the most common CDN content: images, CSS, JavaScript, fonts, and video files. These change infrequently and are identical for every user, making them ideal for caching. Many CDNs also cache HTML pages, API responses, and dynamically generated content with appropriate cache headers. The more you cache at the edge, the less load on your origin. Use the Base64 Encoder to encode small assets for inline embedding when CDN caching is not practical.

Key point: CDNs are not just for static files. Modern CDNs can cache personalised content, run serverless functions at the edge (edge compute), and provide security features like DDoS protection and WAF. They have evolved far beyond simple file caching.

Cache Headers

Cache behaviour is controlled by HTTP headers. Cache-Control: public, max-age=31536000 tells the CDN (and browsers) to cache the response for one year. Cache-Control: no-store prevents caching entirely. Vary: Accept-Encoding tells the CDN to cache separate versions for different encodings (gzip, brotli). ETag and Last-Modified enable conditional requests for revalidation. Inspect cache headers using the cURL Converter to see exactly what your origin is sending.

Cache Invalidation (Purging)

Cache invalidation is famously one of the two hard problems in computer science. When you deploy new code or update content, the CDN may still serve the old cached version. Strategies include: versioned URLs (append a hash to filenames: app.a1b2c3.js — the best approach), purge API (tell the CDN to drop specific cached objects), and short TTLs (set low max-age for frequently changing content). Versioned URLs are preferred because they are instant, reliable, and require no purge API calls.

CDN Providers

Cloudflare: massive free tier, integrated DNS, DDoS protection, Workers (edge compute). Great for most use cases. Fastly: real-time purging, VCL configuration, edge compute (Compute@Edge). Preferred for sites that need instant cache invalidation. CloudFront: deep AWS integration, Lambda@Edge for compute. The natural choice if you are already on AWS. Akamai: the original CDN, huge network, enterprise-focused. Bunny.net: affordable, simple, good performance. Format CDN configuration JSON with the JSON Formatter.

Key point: Cloudflare's free plan is sufficient for most small-to-medium sites and includes DNS, SSL, and basic DDoS protection. Start there unless you have specific needs that require another provider.

Edge Compute

Modern CDNs let you run code at the edge: Cloudflare Workers, Fastly Compute@Edge, CloudFront Functions, and Deno Deploy. Edge compute enables personalisation, A/B testing, authentication, and API routing at the CDN layer — reducing latency and origin load. It is particularly powerful for use cases like geolocation-based content, header manipulation, and URL rewriting.

Security Benefits

CDNs provide significant security benefits: DDoS absorption (the CDN's massive network absorbs volumetric attacks before they reach your origin), Web Application Firewall (WAF) rules, bot mitigation, and TLS termination at the edge. By hiding your origin IP behind the CDN, you also prevent direct attacks on your infrastructure. Use the IP Lookup tool to verify that your CDN is properly masking your origin IP address.

When to Use a CDN

Use a CDN when your users are geographically distributed, when your site serves significant static content, when you need DDoS protection, or when you want to reduce origin server load and bandwidth costs. The only reason not to use a CDN is if your users are all in the same data center as your servers (rare) or if caching creates correctness issues for your specific use case.

Key point: A CDN is one of the highest-impact performance optimizations you can make. Adding a CDN in front of your application typically reduces page load times by 40-60% for geographically distributed users, and it often costs nothing (Cloudflare free tier) or very little.
← Back