CDN Architecture Patterns: Choosing the Right Design for Your Scale
Every web application embeds a CDN architecture decision, whether the team recognizes it or not. A static marketing site, a dynamic SaaS dashboard, a real-time API, and an e-commerce platform each demand fundamentally different CDN configurations. Choosing the wrong pattern means either overpaying for features you do not need or hitting scaling walls that the pattern cannot accommodate. For a comprehensive overview, see our guide on CDN Architecture: Edge, Origin, and Everything Between — FlyFish NWA.
This guide presents seven CDN architecture patterns in order of complexity. Each pattern includes its ideal use case, the technical tradeoffs, and when to graduate to the next pattern. The goal is to match your architecture to your current scale while leaving room to evolve.
What Is the Static Site CDN Pattern?
The simplest and most efficient CDN architecture: pre-built HTML, CSS, JavaScript, and images served entirely from CDN edge storage. No origin server processes requests.
How it works. A build pipeline generates static HTML files. These files are uploaded to CDN edge storage (Cloudflare Pages, Netlify, Vercel, AWS S3 + CloudFront). The CDN serves every request from cache with no origin involvement. TTFB is consistently 5–50 ms globally because there is no server-side processing.
Ideal for: marketing sites, documentation, blogs, portfolios, landing pages, and any site where content changes only during deployments (not in real time).
Limitations. No server-side dynamic content (personalization, user-specific pages). No real-time data (must rebuild and redeploy to update). Build times grow linearly with page count (10,000 pages may take 10+ minutes to build). These limitations lead to the next patterns when the application outgrows static delivery.
Cache strategy. Set Cache-Control: public, max-age=31536000, immutable for fingerprinted assets (style.a1b2c3.css). Set Cache-Control: public, max-age=3600, stale-while-revalidate=86400 for HTML pages. This combination ensures assets are cached for a year while HTML refreshes hourly with instant stale delivery during revalidation. For the underlying caching mechanics, see CDN Caching Strategies.
How Does the Jamstack CDN Pattern Work?
Jamstack extends the static pattern by adding dynamic functionality via client-side APIs and edge functions, without requiring a traditional application server.
| 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 |
Architecture. Pre-rendered HTML pages are served from CDN edge (same as static pattern). Dynamic functionality (search, comments, authentication, form submissions) is handled by: client-side JavaScript calling external APIs (headless CMS, search-as-a-service, auth providers), or CDN edge functions that execute server-like logic at the edge (API proxying, authentication, data fetching).
Benefits over traditional server rendering. Near-zero TTFB (pre-rendered HTML served from edge), infinite horizontal scaling (CDN handles traffic spikes), reduced attack surface (no application server to exploit), simplified operations (no server management, patches, or scaling configuration), and lower cost (CDN free tiers handle significant traffic).
When Jamstack fits. Content-driven sites with moderate interactivity: blogs with comments, documentation with search, marketing sites with forms, and e-commerce product catalogs backed by headless commerce APIs. For full-featured e-commerce, see the patterns in CDN for E-Commerce.
When Jamstack breaks down. Applications requiring real-time, user-specific rendering on every request: social feeds, personalized dashboards, collaborative editing, and applications with millions of unique pages that cannot be pre-rendered at build time.
What Is the API-First CDN Pattern?
The API-first pattern places the CDN between client applications and backend APIs, caching and accelerating API responses rather than HTML pages.
Architecture. Client applications (web SPA, mobile apps, third-party integrations) send API requests through the CDN. The CDN caches GET responses based on URL, query parameters, and authorization scope. POST/PUT/DELETE requests pass through to origin. Edge functions handle request transformation, response filtering, and authentication validation.
Cache design for APIs. The critical difference from page caching: API responses are often partially cacheable. A product listing API may be cacheable for all users (public data), while a user profile API is specific to each authenticated user (private). The CDN cache key must distinguish between public and private responses using the Authorization header or a custom user-scope header. See API Acceleration via CDN for detailed cache key patterns.
TTL strategy by endpoint type:
| Endpoint Type | Cache TTL | Cache Key |
|---|---|---|
| Reference data (countries, categories) | 1 hour+ | URL only |
| Product listings | 5–15 minutes | URL + query params |
| Search results | 1–5 minutes | URL + query params |
| User-specific data | 30–60 seconds or no-cache | URL + auth scope |
| Real-time data (notifications) | No cache | N/A |
How Does the Microservices CDN Pattern Scale?
In a microservices architecture, the CDN acts as the unified entry point, routing requests to multiple backend services and caching responses from each.
Architecture. The CDN receives all incoming requests on a single domain. CDN routing rules (path-based or header-based) direct requests to the appropriate microservice origin: /api/products routes to the product service, /api/users routes to the user service, /assets routes to the storage service. Each route has independent caching, security, and rate limiting rules.
Benefits. Single domain for clients (no CORS issues), per-service cache optimization, per-service rate limiting and WAF rules, and centralized SSL termination. The CDN becomes the API gateway, eliminating the need for a separate gateway layer in many architectures.
Origin health management. Configure independent health checks per origin. If the product service is down, the CDN serves stale cached product data while returning errors only for product mutations. Other services remain unaffected. This graceful degradation is impossible with a monolithic origin. For health check patterns, consult the CDN Troubleshooting Guide.
What Is the Hybrid SSR + CDN Pattern?
The hybrid pattern combines server-side rendering for dynamic pages with CDN caching for performance. This is the dominant pattern for modern full-stack frameworks (Next.js, Nuxt, SvelteKit, Remix).
Architecture. The origin server renders HTML for each request (SSR). The CDN caches the rendered HTML with a short TTL (30 seconds to 5 minutes) using stale-while-revalidate. Subsequent requests receive the cached HTML instantly while the CDN revalidates in the background. Static assets use long TTLs with immutable caching.
Incremental Static Regeneration (ISR). Next.js popularized this hybrid approach: pages are statically generated at build time and served from CDN, but automatically regenerated in the background when the TTL expires. The CDN serves the stale version instantly while the origin generates a fresh version. This combines the performance of static delivery with the freshness of server rendering.
When to use. Applications that need both server rendering (SEO, personalization, real-time data) and CDN performance: WordPress with full-page caching, e-commerce product pages with dynamic pricing, news sites with frequently updated content, and SaaS dashboards with shared data views.
Cache invalidation challenges. The hybrid pattern's Achilles heel is cache invalidation. When content changes, the CDN cache must be purged. For sites with thousands of interconnected pages (changing a category affects all products in that category), targeted purging becomes complex. Implement webhook-based purging: the CMS fires a webhook on content change, and the CDN API purges affected URLs. See CDN Cache Invalidation for the detailed playbook.
How Does Multi-Region Active-Active CDN Architecture Work?
Multi-region active-active deploys identical application stacks in multiple regions, with the CDN routing each user to the nearest healthy region. This pattern provides the lowest latency and highest availability for global applications.
Architecture. Deploy application origins in three or more regions (US-East, EU-West, APAC-Singapore is a common starting set). Each origin is a complete, independent stack (application servers, databases, caches). The CDN uses geographic routing to direct each user to the nearest origin. If a region fails, the CDN health check detects the failure and routes to the next nearest healthy region.
Data synchronization. The hardest problem in active-active is keeping data consistent across regions. Options: eventual consistency (data propagates asynchronously, suitable for most read-heavy workloads), conflict-free replicated data types (CRDTs, for collaborative editing), leader-follower with regional read replicas (writes go to leader region, reads served locally), and region-pinned data (each user's data lives in one region, the CDN routes them there).
CDN configuration. Configure multiple origins with geographic routing and health checks. Set the health check interval to 10–30 seconds with a 2-of-3 failure threshold. Configure an origin shield per region to reduce origin load. Set stale-while-revalidate and stale-if-error headers to serve cached content during failover transitions.
Cost implications. Active-active multiplies infrastructure costs by the number of regions. Mitigate by: using serverless backends (pay per request, not per server per region), right-sizing regional capacity (smaller instances in low-traffic regions), and leveraging CDN caching to reduce the compute load at each origin. Monitor costs using the strategies in CDN Cost Optimization.
How Do You Design CDN-Based Disaster Recovery?
CDN-based disaster recovery uses the CDN's global infrastructure to maintain service availability during origin outages, ranging from graceful degradation to full failover.
Stale content serving. The simplest disaster recovery: configure stale-if-error to serve cached content when origin returns errors. This keeps the site readable (though not updatable) during outages. Set Cache-Control: stale-if-error=86400 to serve stale content for up to 24 hours during origin failure.
Static failover page. For applications that cannot serve stale content, configure a static failover page hosted on a separate, highly available origin (e.g., S3 static website). When the primary origin fails health checks, the CDN serves the failover page. This page communicates the outage and provides alternative contact methods.
Multi-origin failover. Configure primary and backup origins. When the primary fails, the CDN automatically routes to the backup. The backup can be a full application stack in another region (active-passive) or a read-only replica (degraded mode). Test failover regularly—the CDN Testing Strategies guide covers failover drill methodology.
How Do You Choose the Right Pattern for Your Scale?
Pattern selection should match your current needs with room to grow. Over-engineering the CDN architecture wastes resources; under-engineering creates scaling emergencies.
| Stage | Traffic | Recommended Pattern | CDN Cost |
|---|---|---|---|
| Early startup | <10K visitors/day | Static site or Jamstack | Free tier |
| Growing startup | 10K–100K/day | Hybrid SSR + CDN | $50–500/mo |
| Scale-up | 100K–1M/day | API-first or Microservices | $500–5K/mo |
| Enterprise | 1M+ /day | Multi-region active-active | $5K–50K+/mo |
Migration between patterns. Pattern evolution should be incremental, not revolutionary. Move from static to Jamstack by adding edge functions. Move from Jamstack to hybrid SSR by adding a server rendering layer for dynamic pages. Move from single-region to multi-region by deploying a second origin and adding CDN geographic routing. Each transition builds on the previous pattern rather than replacing it. Plan the CDN transition alongside the CDN Migration Guide to avoid disruption.
The right architecture pattern is the simplest one that meets your current requirements with a clear upgrade path to the next level. Start simple, measure performance with Real User Monitoring, and evolve the architecture as real data demands it.