CDN Origin Fetch Explained: Origin Address, Origin Host, and What Happens on a Cache Miss
To understand origin fetch, picture a cafeteria. The CDN edge node is a branch store outside your door; the origin (your server) is the central kitchen. When a customer orders, the branch serves it instantly if it is ready (cache hit); if not, someone runs back to the kitchen (origin fetch). Origin fetch is simply the action of an edge node retrieving data from the origin. Many site owners treat the "origin" field in CDN settings as a fill-in-whatever box, then see 502s and broken images after going live. This article explains everything about origin fetch at once.
1. What Is Origin Fetch, and When Does It Happen
Origin fetch is the process in which a CDN edge node requests content from your origin server when it has no cache or the cache has expired. A CDN does not copy your entire site to every node; it pulls content on demand when users request it.
Common triggers of origin fetch:
- Cache miss: the edge node does not yet have the requested content;
- Cache expiry (TTL reached): content is older than the configured cache duration, so the node must re-fetch;
- Cache purge: you cleared the cache in the console, so the next request fetches from origin;
- Dynamic content: content that is never cached (login state, cart APIs) fetches from origin every time.
To understand cache hits and how to improve the hit ratio, see CDN Cache Strategy.
2. Origin Address, Origin Domain, and Origin Host
These three terms are the easiest to mix up. Remember one sentence: the origin address tells the CDN "which server", and the origin Host tells the CDN "under which domain name to fetch content on that server".
- Origin address: can be an IP (such as
203.0.113.10) or an origin domain (such asorigin.example.com); it identifies the server itself; - Origin Host: the Host field in the HTTP header of the origin request, usually your website domain
www.example.com. Your web server (Nginx/Apache) uses the Host to decide which site configuration to return; - Origin domain: on some CDN platforms, the domain used for DNS resolution during origin fetch; effectively close to the domain form of the origin address.
A classic pitfall: if you host multiple sites on one server (distinguished by different Host values) and set the origin Host wrong, the CDN fetches another site's content — pages appear "cross-wired". Beginners trip over this most often.
3. How to Choose an Origin Protocol
The origin protocol decides how the "CDN → origin" segment connects. There are usually three modes:
| Origin Protocol | Description | When to Use |
|---|---|---|
| HTTP | Fetch origin in plaintext | Origin has no certificate; simplest |
| HTTPS | Fetch origin over encryption | High security requirements; origin has a certificate |
| Follow | Match the user's request | When you are sure both ends match |
Beginners should start with HTTP origin fetch (content travels inside the CDN network, so the risk is manageable) and upgrade to HTTPS later. For more detail on origin protocols, see HTTPS Certificate Configuration on a CDN.
4. What Actually Happens on a Cache Miss
Take a user opening your page as an example. The cache-miss flow looks like this:
- The user requests
https://www.example.com/image.jpg, and DNS resolves to the nearest CDN node; - The node checks its cache and finds the file missing (or expired);
- The node sends an origin request to your server using "origin address + origin Host";
- The server returns the content (HTTP 200);
- The node writes the content into its local cache and starts a TTL timer;
- The node returns the content to the user, with a marker such as
X-Cache: MISSin the response headers; - When the same file is requested again, it hits the cache directly (
X-Cache: HIT) with no origin fetch.
This is why the first visit is slow and later visits are fast. The initial fetch adds tens to hundreds of milliseconds of latency, which is normal.
5. Origin Timeouts and Failures: What the CDN Does
Origin fetch does not always succeed. Common failures and their symptoms:
- Origin timeout: the origin responds too slowly (slow queries, high load); the CDN disconnects after waiting past the threshold (commonly 5-30 seconds), and the user sees 504 or 502;
- Origin down: the server is offline, the fetch fails, and the CDN returns 502 Bad Gateway;
- Origin rejects: the origin firewall blocks CDN node IPs, or the origin returns 403 — users see an error too.
CDN fallback mechanisms:
- Retry: some CDNs retry the origin fetch once;
- Stale cache fallback (stale-while-revalidate): on fetch failure, serve the previous cached copy instead of erroring — this is the most recommended option to enable;
- Origin throttling / circuit breaker: when the origin cannot keep up, the CDN pauses fetching and returns 429 or a degraded page.
Enable "serve stale content on origin failure" in the CDN console, and protect the origin (only allow CDN node IPs). For related architecture, see Origin Shield and Cache Architecture.
6. FAQ
Q1: Can the origin Host be an IP? Not recommended. The origin Host should be a domain name because the server matches sites by Host; filling in an IP makes the server return the default site or a 404.
Q2: Why does my origin log still show many requests after enabling the CDN? That is normal. These are usually origin-fetch requests from CDN node IPs. To tell them apart, check the source IP ranges or User-Agent in the logs, or look at the CDN's X-Cache markers.
Q3: Does origin fetch expose my origin IP? If fetch requests go directly from nodes to the origin, the IP can be discovered. Enable origin protection, allow only CDN node IPs, and hide the origin address — see Origin Shield and Cache Architecture.
Q4: Why is my cache hit ratio low? Common causes are URLs with query parameters (so every URL is different), a TTL set too short, or dynamic endpoints without cache rules. For optimization, see Improving CDN Cache Hit Ratio.