ARTICLE - CDN & Network

CDN Origin Fetch Explained: Origin Address, Origin Host, and What Happens on a Cache Miss

Origin fetch is the most core and most misunderstood CDN concept. This guide uses everyday analogies to explain what origin fetch is, the difference between the origin address and origin Host, how to choose an origin protocol, and what happens on cache misses, timeouts, and failures.

2026-08-12 16IDC Original

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 as origin.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:

  1. The user requests https://www.example.com/image.jpg, and DNS resolves to the nearest CDN node;
  2. The node checks its cache and finds the file missing (or expired);
  3. The node sends an origin request to your server using "origin address + origin Host";
  4. The server returns the content (HTTP 200);
  5. The node writes the content into its local cache and starts a TTL timer;
  6. The node returns the content to the user, with a marker such as X-Cache: MISS in the response headers;
  7. 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.

  • 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.
  • 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.
  • 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.
  • 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.

Integration & Code Examples

Example 1: Confirm the origin hostname and origin HOST header

CDN_HOST="www.example.com"
ORIGIN_HOST="origin.example.com"
ORIGIN_IP="203.0.113.10"
dig +short A "$ORIGIN_HOST"
# Simulate a CDN fetch: connect to the origin IP but send the CDN hostname
curl -sI --resolve "$CDN_HOST:443:$ORIGIN_IP" "https://$CDN_HOST/" | head -n 3
# When the origin routes by Host, the wrong value yields a 404 or default vhost
curl -sI --resolve "$ORIGIN_HOST:443:$ORIGIN_IP" "https://$ORIGIN_HOST/" | head -n 3
# Print status codes only, so both Host values can be compared in a loop
for h in "$CDN_HOST" "$ORIGIN_HOST"; do
  printf '%-22s ' "$h"
  curl -s -o /dev/null -w "%{http_code}\n" --resolve "$h:443:$ORIGIN_IP" "https://$h/"
done
# Different codes for the two Host values all but prove a HOST misconfiguration

A misconfigured origin HOST shows up as 'the origin works directly but everything 404s through the CDN'; these two commands reproduce and localise it.

Example 2: A minimal cache for static assets on the origin

proxy_cache_path /var/cache/origin levels=1:2 keys_zone=origin_static:50m
                 max_size=5g inactive=30m use_temp_path=off;

server {
    listen 443 ssl;
    server_name origin.example.com;

    location ~* \.(?:css|js|png|jpg|svg|woff2)$ {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_cache origin_static;
        proxy_cache_valid 200 30m;
        proxy_cache_lock on;
        add_header X-Origin-Cache $upstream_cache_status always;
    }
}

proxy_cache_lock is the most overlooked line in an origin cache: it collapses concurrent fetches for one URL into a single request, so a cache stampede cannot flatten the backend.

Origin Error Codes: What 502, 504, 403 and 429 Each Point To

Route origin failures by status code first: unreachable origin, wait timeout, origin rejection, and CDN circuit breaking. Once the code is known, you know whether to change the origin or the CDN settings.

502 differs from 504 by connection state: the TCP connection succeeds but no body arrives within the threshold gives 504, while a closed port or a dead process gives 502. The thresholds listed in this article are 5-30 seconds.

Status Failing leg Cause described here Check first
502 Origin unreachable Origin down, fetch request failed Whether the origin process is listening on the origin port
504 Origin timeout Origin slower than the 5-30 second threshold Slow queries, high load, RTT on the fetch path
403 Origin rejection Firewall blocked CDN node IPs Whether the allowlist covers only CDN ranges
429 CDN circuit breaking Fetch rate limiting, origin saturated Origin capacity and whether concurrent fetches are collapsed
200 + X-Cache: MISS Normal fetch First request or freshly purged cache Nothing; this is expected

Neither 403 nor 429 is fixed by retries. A 403 belongs to the origin allowlist, and a 429 means the origin is at its capacity edge: collapse concurrent fetches and shorten each fetch instead of adding attempts.

Three Fallbacks for a Cache Stampede: Collapse, Stale Cache, Degrade

At the moment a hot object's TTL expires, concurrent requests landing on the same node all evaluate as MISS. That is what proxy_cache_lock in the sample config is for: fetches for one URL collapse into a single request, so the backend is not flattened.

The first fallback when a fetch fails is the stale copy (stale-while-revalidate). The node keeps serving the last usable object, at the cost of being up to one TTL behind the origin; for lists and other content where brief staleness is tolerable this usually beats an error page.

Rate limiting and degradation come last: when the origin has been unavailable for a while, the CDN pauses fetches and returns 429 or a fallback page. That layer only works together with an origin allowlist covering CDN node IPs, otherwise direct requests that bypass the CDN still reach the backend.

Limitations

  • A CDN does not copy your entire site to every node; it pulls content on demand when users request it.
  • This article reflects public information as of 2026-08-12; terms, prices and quotas follow the provider's current published terms.
  • Third-party capability and limit statements follow their official documentation; no further commitment is implied here.
  • Licensing, filing and data-residency decisions must be verified against the regulations of your operating region.

FAQ

Which origin address format works, IP or domain?

Yes, both work, but the origin host still has to be a domain name. The origin address only tells the CDN which server to reach, while the origin host decides which site that server returns; on a box hosting several sites, filling in an IP yields the default site or a 404. Hide origins with shielding, not with IPs.

How does origin host differ from the origin address?

Typically the address picks the server and the host header picks which site on it. When the address is a domain such as origin.example.com, the CDN resolves it to an IP first and then sends the request with the host header attached. With several sites on 1 machine the header must match the site, or users see the wrong content.

Why does origin fetching keep returning 502?

Typically a 502 means the CDN could not reach the origin or got a bad response, so confirm the origin answers on its own first. Reproduce with curl against the origin IP plus a Host header, then check whether the origin firewall blocks CDN node IPs and whether the origin port is open; timeouts commonly run 5–30 seconds, so slow queries count as failures.

When should you avoid stale-cache fallback?

Avoid it where stale content is unacceptable. With fallback on, a failed origin fetch keeps serving the previous copy, so prices and stock counts can be out of date; login and cart endpoints are not cached, so they are unaffected. Keep the fallback but shorten TTL on those paths instead.

Related Providers

  • Cloudflare: Use it when per-path origin HOST and cache-miss logs need to be compared.
  • AWS CloudFront: Use it when the origin is object storage or a load balancer and origin timeouts need tuning.
  • Aliyun CDN: Use it when several origins need weights and an origin domain override.

Community & Resources

Learning resources and tools

Original source: 16IDC Original ↗