CDN for Static Sites: The Perfect Match Explained
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:
| Metric | Dynamic Site + CDN | Static Site + CDN | Improvement |
|---|---|---|---|
| Cache Hit Ratio | 40-70% | 95-99% | +40-55% |
| TTFB (global median) | 120-300ms | 15-45ms | 70-85% faster |
| Origin requests at peak | 30-60% of total | 1-5% of total | 90%+ offload |
| Downtime risk | Origin-dependent | Near zero | Eliminated |
| Monthly hosting cost | $50-500+ | $0-20 | 80-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.
| Metric | Edge Processing | Origin Processing | Improvement |
|---|---|---|---|
| Latency (p50) | 8–15 ms | 120–300 ms | 15–20x faster |
| Cache Hit Ratio | 85–95% | N/A | Reduces origin load |
| TLS Handshake | 1–5 ms (nearby PoP) | 50–150 ms | 10–30x faster |
| Bandwidth Cost | $0.01–0.04/GB | $0.05–0.12/GB | 3–5x cheaper |
| Availability | 99.99% (multi-PoP) | 99.9% (single DC) | 10x fewer outages |
The Build-Deploy-Serve Pipeline
- 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.
- Deploy — The build output (HTML, CSS, JS, images) uploads to CDN edge storage. Atomic deploys ensure visitors never see a partial update.
- Serve — The CDN serves pre-built files from the nearest edge location. No application server processes requests. No database connections open.
- 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.
| Feature | Netlify | Vercel | Cloudflare Pages |
|---|---|---|---|
| Edge locations | 200+ | 100+ | 300+ |
| Free bandwidth | 100 GB/month | 100 GB/month | Unlimited |
| Build minutes (free) | 300/month | 6,000/month | 500/month |
| Atomic deploys | Yes | Yes | Yes |
| Edge functions | Yes | Yes (middleware) | Yes (Workers) |
| ISR support | Limited | Native | Via 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:
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:
- Time to First Byte (TTFB) — 15-45ms globally for cached HTML pages. Compare this with 200-800ms for typical dynamic applications.
- Largest Contentful Paint (LCP) — Under 1.2 seconds on 4G mobile connections when images are properly optimized with Brotli compression and modern formats (WebP, AVIF).
- First Contentful Paint (FCP) — Under 0.8 seconds on broadband. Static HTML without server-side processing renders almost instantly.
- Cumulative Layout Shift (CLS) — Under 0.05 when images have explicit dimensions and fonts use font-display: swap.
- PageSpeed Insights score — Consistently 95-100 for well-optimized static sites, directly impacting Core Web Vitals and search rankings.
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:
- Site search — Pagefind generates a search index at build time that runs entirely in the browser. For larger sites, Algolia provides hosted search with sub-50ms query response times.
- Forms — Submissions route to Netlify Forms, Formspree, or a custom serverless function. The form HTML is static; the submission handler is a separate service.
- Comments — Giscus stores comments in GitHub Discussions. Utterances maps comments to GitHub Issues. Both load asynchronously without affecting initial page load performance.
- Authentication — Auth0, Clerk, or Firebase Authentication handle user identity. Protected content loads conditionally via client-side JavaScript after authentication.
- E-commerce — Snipcart overlays a shopping cart on static product pages. Shopify Buy SDK integrates checkout flows. Product pages remain static and cacheable while transactions process through API calls.
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.