CDN for Static Sites: The Perfect Match Explained

· Alex Petrov · 9 min read

Static sites and CDNs form a natural partnership because every page is a pre-built file that is identical for every visitor. Unlike dynamic applications that generate unique responses per request, static sites allow CDNs to cache every page at every edge location with near-perfect cache hit ratios of 95-99%. This combination delivers sub-50ms Time to First Byte (TTFB) from anywhere in the world, eliminates origin server dependencies, and reduces hosting costs to near zero. Understanding how CDNs work helps explain why static content is the ideal workload for edge delivery.

Why Are Static Sites the Perfect CDN Workload?

The core challenge of CDN caching is deciding what to cache and when to invalidate. Static sites eliminate this challenge almost entirely. Every HTML page, CSS stylesheet, JavaScript file, and image is a fixed artifact generated at build time. No database queries execute at request time. No server-side rendering occurs. No personalization logic modifies the response based on who is asking. For foundational context, read What Is a CDN? The Complete Beginner's Guide — FlyFish NWA.

This architectural simplicity translates to measurable performance advantages:

CDN Network Topology — How content flows from origin to edge servers closest to usersCDN Network Topology — How content flows from origin to edge servers closest to users CDN Network Topology — Content Delivery Flow U User A Tokyo U User B London U User C New York Edge Server Tokyo PoP Edge Server London PoP Edge Server New York PoP Mid-Tier Cache Origin Shield Origin Server Your Server Request Cache Miss Fetch Cache Hit → Instant Response
Figure 1: CDN Network Topology — How content flows from origin to edge servers closest to users
MetricDynamic Site + CDNStatic Site + CDNImprovement
Cache Hit Ratio40-70%95-99%+40-55%
TTFB (global median)120-300ms15-45ms70-85% faster
Origin requests at peak30-60% of total1-5% of total90%+ offload
Downtime riskOrigin-dependentNear zeroEliminated
Monthly hosting cost$50-500+$0-2080-100% savings

When 99% of requests are served from edge cache, the origin server barely matters. If the origin goes offline during a content update, existing cached content continues serving visitors without interruption. This resilience is why static sites achieve 99.99%+ uptime without complex failover configurations, a significant CDN benefit that dynamic applications cannot match.

What Is JAMstack Architecture and How Does It Use CDNs?

JAMstack (JavaScript, APIs, Markup) is the dominant architecture for modern static sites. The principle is straightforward: pre-render every page as static HTML during a build step, serve the HTML from a CDN, and add dynamic functionality through client-side JavaScript calling backend APIs.

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages

The Build-Deploy-Serve Pipeline

  1. Build — A static site generator (Hugo, Astro, Eleventy, Next.js, Gatsby) compiles templates and content into HTML files. A 500-page site builds in 5-30 seconds with modern generators.
  2. Deploy — The build output (HTML, CSS, JS, images) uploads to CDN edge storage. Atomic deploys ensure visitors never see a partial update.
  3. Serve — The CDN serves pre-built files from the nearest edge location. No application server processes requests. No database connections open.
  4. Interact — Client-side JavaScript handles dynamic features (search, forms, comments) by calling serverless functions or third-party APIs.

This separation between content delivery and dynamic processing means the CDN layer stays simple, fast, and highly cacheable while interactive features operate independently through API calls.

Which Deployment Platforms Offer the Best CDN Integration?

Three platforms have emerged as the leaders for static site deployment, each with built-in CDN infrastructure that eliminates manual CDN setup:

Netlify

Netlify pioneered the deploy-to-CDN workflow for static sites. Push code to Git, Netlify builds it, and deploys to its global CDN automatically. Key features include atomic deploys where the entire site switches at once, instant rollbacks to any previous deploy, branch-based deploy previews for testing, built-in form handling and serverless functions, and automatic HTTPS with Let's Encrypt certificates. Netlify's free tier includes 100 GB bandwidth per month and 300 build minutes, sufficient for most personal and small business sites.

Vercel

Vercel is the company behind Next.js and offers the tightest integration with that framework. Vercel supports Incremental Static Regeneration (ISR), which rebuilds individual pages in the background without redeploying the entire site. This is particularly valuable for sites with thousands of pages where full rebuilds take minutes. Vercel's edge functions enable dynamic logic at CDN edge locations, blurring the line between static and dynamic.

Cloudflare Pages

Cloudflare Pages runs on the same global network used by Cloudflare's CDN, spanning 300+ cities worldwide. The standout advantage is unlimited free bandwidth, making it the most cost-effective option for high-traffic static sites. Cloudflare Workers integration enables server-side logic at the edge, and the platform supports all major static site generators through its build system.

FeatureNetlifyVercelCloudflare Pages
Edge locations200+100+300+
Free bandwidth100 GB/month100 GB/monthUnlimited
Build minutes (free)300/month6,000/month500/month
Atomic deploysYesYesYes
Edge functionsYesYes (middleware)Yes (Workers)
ISR supportLimitedNativeVia Workers

How Should You Configure Caching for Static Sites?

The optimal caching strategy for static sites uses a two-tier approach that maximizes cache hit ratios while ensuring content freshness:

CDN Request Flow — Step-by-step lifecycle of a content requestCDN Request Flow — Step-by-step lifecycle of a content request CDN Request Flow — From Browser to Edge CDN Request Lifecycle Step 1 DNS Lookup Step 2 TCP Connect Step 3 TLS Handshake Step 4 Edge Server Step 5 Cache Check Step 6 Response Cache HIT → 5ms response Cache MISS → Fetch origin 0ms ~50ms (cache hit) ~200ms (cache miss)
Figure 2: CDN Request Flow — Step-by-step lifecycle of a content request

Hashed Assets: Cache Forever

CSS, JavaScript, and image files should include a content hash in their filename (e.g., app.3f2a9b1c.js, styles.e7d4c8a2.css). Because the hash changes whenever the file content changes, these files can be cached with the most aggressive settings possible:

Cache-Control: public, max-age=31536000, immutable

This tells the CDN and browser to cache the file for one year and never revalidate. When the content changes, the build process generates a new hash, creating a new URL that the CDN treats as a completely different file. Old versions expire naturally from the cache. This strategy achieves a 100% cache hit ratio for repeat visitors because every asset request matches a cached version.

HTML Pages: Short TTL with Revalidation

HTML files cannot use content hashing because their URLs must remain stable for SEO, bookmarks, and inbound links. Instead, use short TTLs that balance freshness with performance:

Cache-Control: public, max-age=300, stale-while-revalidate=86400

This caches HTML for 5 minutes, then serves the stale version for up to 24 hours while revalidating in the background. Visitors always get a fast response while the CDN fetches the latest version asynchronously. Modern deployment platforms bypass TTL-based invalidation entirely by purging all HTML caches instantly on each deploy, ensuring visitors see new content within seconds of deployment.

What Performance Benchmarks Can You Expect?

Static sites on CDN infrastructure consistently achieve elite performance scores. Based on aggregated data from WebPageTest and Google CrUX across thousands of static sites:

These numbers represent the practical ceiling of web performance. No dynamic application architecture can consistently match them because server-side processing, database queries, and template rendering add irreducible latency that static pre-rendering eliminates.

How Do You Handle Dynamic Features on a Static Site?

The JAMstack approach handles dynamic functionality by decoupling it from page delivery. Common patterns include:

Each dynamic feature operates independently, so a search service outage does not affect page delivery, and a form handler error does not prevent visitors from reading content. This fault isolation is a structural advantage of the static-plus-API architecture over monolithic server-rendered applications.

The Bottom Line on CDN Static Sites: Perfect Match

Static sites and CDNs are the most efficient content delivery combination available today. Pre-built HTML eliminates server-side processing, enables 95-99% cache hit ratios, and delivers sub-50ms TTFB worldwide. Modern deployment platforms like Netlify, Vercel, and Cloudflare Pages have reduced the setup from complex CDN configuration to a simple Git push. For content-focused websites, documentation, blogs, marketing sites, and portfolios, a static site on CDN infrastructure delivers elite performance at minimal cost with near-perfect uptime.

External References

References & Standards: RFC 7234 · W3C Web Performance