When an origin server fails, a CDN can sometimes continue serving cached pages, route requests to a backup, or display a controlled maintenance response. This runbook explains how to compare those options, configure them safely, and verify recovery without turning a short outage into a cache or DNS incident.
Overview
A CDN origin failover design separates two questions that are often confused: can the edge serve an existing response, and where should it send a request that still needs the origin? The first question is answered by caching and stale-content policies. The second depends on origin pools, health checks, backup origins, DNS, or application-level routing.
If your website origin server goes down, the CDN may receive connection timeouts, TLS errors, refused connections, or HTTP 5xx responses. A well-designed configuration gives the edge an explicit response for each condition. That response might be a cached page, a request to a secondary origin, or a static maintenance page. Without a defined policy, behavior can vary by CDN, cache status, request type, and provider plan.
The safest design usually has several layers:
- Edge caching: Stores eligible public responses close to visitors.
- Origin health checks: Detects whether an origin is responding correctly.
- Origin failover: Sends eligible requests to a backup origin when the primary is unhealthy.
- Stale-if-error behavior: Permits selected cached responses to remain available during an origin error, where supported.
- Recovery controls: Prevents corrupted, incomplete, or outdated content from remaining after the primary returns.
Failover is not a substitute for backups, database replication, or application recovery. A CDN can protect delivery of cached and static content, but it cannot automatically recreate an unavailable database or preserve a user transaction that never reached the application.
How to compare options
Compare failover methods by the type of failure they cover, the requests they can handle, and the operational work required to keep them accurate. Feature names differ between CDN vendors, so read the current documentation for your plan and test the actual configuration rather than relying on a product label.
| Option | What it protects | Main limitation | Best use |
|---|---|---|---|
| Stale cached responses | Previously cached public pages and assets | Cannot serve uncached or personalized content | Short origin interruptions where existing content is acceptable |
| CDN origin pool failover | Requests that can be served by a compatible secondary origin | Requires synchronized files, application behavior, and data | Websites with a warm or independently operated backup origin |
| Static maintenance page | Basic communication when the application is unavailable | Does not preserve normal site functionality | Controlled incidents and planned maintenance |
| DNS failover | Traffic directed to a replacement endpoint | Resolver and client caching can delay changes; it may bypass the CDN | Infrastructure-level routing when DNS is part of the availability design |
| Application-level recovery | Transactions, sessions, and dynamic workflows | Requires resilient application and data architecture | Commerce, accounts, APIs, and other stateful services |
Begin with the recovery objective for each URL class. A public article may tolerate an older cached version, while a checkout endpoint should not be served from a generic stale cache. Define whether the goal is continued reading, a clear maintenance response, or full transactional availability. That decision should determine your cache rules and failover path.
Also compare the failure signals. Some configurations react to connection failures and timeouts; others can react to selected HTTP status codes. A health check that only requests a homepage may miss a broken database connection or an unhealthy application path. Conversely, an overly strict check can remove a healthy origin because of a nonessential dependency.
For cache behavior, document the response status, cache status, age, and any warning or diagnostic headers produced during an incident. Review your cache-control headers and TTL settings before changing stale behavior. The objective is predictable delivery, not simply the highest possible cache hit rate.
Feature-by-feature breakdown
Health checks
Use a dedicated health-check endpoint rather than assuming that a successful TCP connection proves the website is healthy. The endpoint should test the minimum dependencies required to serve the traffic you intend to fail over. Keep it lightweight, deterministic, and free of user-specific content.
Record the check path, expected status, timeout, interval, failure threshold, and recovery threshold. These settings affect how quickly traffic moves away from an origin and how quickly it returns. Do not set them without considering startup time, deploy behavior, and temporary application load.
Backup origins
A backup origin must be able to serve the same hostname, certificate expectations, paths, and cacheable content as the primary. For static websites, that may mean replicated object storage or a second web server. For dynamic applications, it also means considering database access, sessions, uploads, queues, and external services.
Keep the backup from becoming a permanently untested asset. A scheduled read-only check, content synchronization check, and controlled failover drill can reveal missing files, incorrect environment variables, or an origin that cannot handle production headers.
Stale-if-error and stale serving
Stale serving can keep a previously cached response available when the origin returns an error or cannot be reached. It is most appropriate for public, read-heavy content where a slightly older response is better than an error. It is risky for account pages, cart responses, checkout flows, administrative screens, and responses containing private data.
Use explicit cache keys and exclusion rules. A cached response must not vary incorrectly by cookie, authorization, language, device, or query parameter. The guide to CDN cache keys is useful when reviewing these boundaries. Treat stale content as a deliberate availability trade-off, not as a universal outage fix.
Origin selection and status behavior
Define which failures trigger failover and which responses should pass through unchanged. An origin returning a deliberate 404 should not normally be treated like an unavailable server. A 500 response might indicate an application failure, but automatically retrying every request against another origin can increase load or duplicate a non-idempotent operation.
Be especially cautious with POST, payment, account, and other state-changing requests. Limit automatic retries and failover to methods and paths that your application can safely repeat. For APIs, review authentication, ETags, invalidation, and method handling before enabling any caching or retry rule; the API caching guide covers those concerns in more detail.
DNS failover
DNS failover can redirect a hostname to another endpoint, but it is not instantaneous in every resolver or client. Existing DNS answers may remain in use according to cached TTL behavior, and a DNS change may also remove the protection provided by the CDN if the replacement record points directly to an origin.
Document which layer owns failover: authoritative DNS, the CDN, a load balancer, or the application. Multiple independent failover systems can conflict, create loops, or make incident diagnosis harder. Test the complete chain, including DNS resolution, TLS, CDN routing, origin selection, and the application response.
Maintenance pages and purge decisions
A static maintenance page is a useful final fallback, especially when both the primary and backup application are unavailable. Host it in a way that does not depend on the failed origin, and make sure it has a clear cache policy. Include a status message, a support or incident link where appropriate, and a response status that accurately reflects the condition.
Do not purge all CDN content automatically when an origin fails. Purging removes the material that may be keeping the site available. Purge only content known to be incorrect, exposed, or incompatible with the recovery state. After recovery, invalidate deliberately changed objects and confirm that new responses are being fetched from the restored origin.
Best fit by scenario
- Content publishing site: Use CDN edge caching with carefully bounded stale serving for public pages and assets. Keep publishing, previews, and authenticated administration uncached or separately controlled.
- Marketing site: A static backup origin or maintenance page may provide a simple recovery path. Confirm that forms, analytics, and contact workflows have independent handling.
- Online store: Cache public catalog content cautiously, but exclude cart, checkout, customer, inventory-sensitive, and payment paths. A backup origin must share reliable application data; stale product pages cannot replace transaction recovery.
- API platform: Favor health checks, explicit retry rules, rate protection, and application-level redundancy. Avoid treating every API response as cacheable or every request as safe to repeat.
- Small VPS deployment: Start with a CDN, a tested maintenance page, documented DNS access, and backups. Add a second origin only when its data synchronization and operational ownership are clear.
- High-change deployment environment: Use versioned assets, controlled cache invalidation, and a staged recovery test. A failover origin should run a known compatible release rather than whichever files happen to be present.
For a broader infrastructure review, pair this runbook with a website hosting performance benchmark and the cache configuration matrix. Those checks help separate origin capacity problems from CDN configuration problems.
When to revisit
Review the runbook at least twice a year and after any change to the CDN, DNS provider, hosting platform, origin architecture, cache rules, or application deployment process. Also revisit it before a migration, a planned maintenance window, or an event expected to increase traffic.
During each review, confirm the current feature names, plan restrictions, configuration paths, status-code behavior, and provider-specific commands. These details can change even when the underlying design remains sound. Check that certificates, origin credentials, health-check paths, allowlists, and backup content are still valid.
Run a controlled drill with an agreed rollback plan:
- Capture normal responses, cache headers, origin headers, and key user journeys.
- Make the primary origin unavailable in a controlled environment or maintenance window.
- Test cached pages, uncached pages, assets, APIs, authentication, forms, and transactions separately.
- Confirm the expected failover path, response status, cache status, and monitoring alerts.
- Restore the primary origin and verify that new content, deployments, and invalidations work normally.
- Record gaps, assign owners, and update the runbook with the tested commands and decision points.
The final measure of CDN high availability is not whether a dashboard says an origin is healthy. It is whether a known request receives the intended response during failure, whether unsafe requests are protected from accidental retries or caching, and whether recovery returns the site to a consistent state. Keep those tests current, and origin failover becomes an operational capability rather than an unverified checkbox.