A high-traffic WordPress publisher runs Cloudflare in front of a 4-vCPU origin. The Cloudflare cache hit ratio is 88%, which sounds good until you do the math: with 30 PoPs and 12% cold-miss requests, each PoP independently re-fetches the same uncached URLs from origin. A single popular post update triggers ~30 origin requests for the same HTML in the first 10 minutes, one per PoP. Origin CPU spikes. Page load slows. The honest fix is origin shield — an intermediate cache tier that consolidates edge misses before they reach origin.
What’s happening
A CDN without origin shield looks like this:
Visitor → PoP-FRA ──┐
Visitor → PoP-IAD ──┼─→ Origin (sees N concurrent misses for the same URL)
Visitor → PoP-SYD ──┘
When an URL is uncached, every PoP fetches it independently. For a global audience and a popular URL, origin sees min(N_pops, concurrent_requesters) simultaneous misses.
With origin shield:
Visitor → PoP-FRA ──┐
Visitor → PoP-IAD ──┼─→ Shield-EWR ─→ Origin (sees 1 miss, returns to shield, shield fans out)
Visitor → PoP-SYD ──┘
All edge misses funnel through a designated PoP (the shield) before reaching origin. The shield caches the response and serves it back to other PoPs without going to origin a second time.
The mechanics differ by provider:
- Cloudflare Tiered Cache — Pro plans get a single shield (Smart Tiered Cache), Enterprise gets multiple regional shields. Smart Tiered Cache picks the shield based on Argo data; you don’t choose it manually.
- Fastly Origin Shield — pick one POP as the shield. All edge misses route through it before hitting origin.
- AWS CloudFront Origin Shield — pick an AWS region. Edge requests for an uncached object route through that region’s CloudFront cache before origin.
- BunnyCDN Origin Shield — pick a “main” PoP. Other PoPs treat it as their origin.
- KeyCDN — does not offer origin shield as a configured feature; the way to get the effect is to put a separate caching proxy in front of origin and treat it as origin from KeyCDN’s perspective.
The traps:
- Shield region matters. Pick a shield in the wrong region and you’ve added latency for non-shield-region PoPs without saving anything. A North American audience served by a shield in Sydney pays a 200ms round-trip on every miss.
- Cache-Key fragmentation defeats it. If your origin returns different responses based on a header the CDN keys on (Vary: User-Agent, Vary: Cookie), the shield caches one entry per variant. WordPress with a chatty plugin that varies on cookies sees no shield benefit.
- The shield is also subject to cache TTL. A shield serving a 30-second-old cached response is still serving from cache. A shield with a 30-minute TTL absorbs more origin traffic than one with a 60-second TTL — at the cost of staleness on purge gaps.
How to verify
Measure your current origin request rate vs CDN edge request rate:
# At origin nginx, count requests per minute by source IP class
awk '{
if (system("ipcalc -c " $1 " 2>/dev/null") == 0) {
print substr($4, 2, 17), $1
}
}' /var/log/nginx/access.log \
| awk '{print $1}' | uniq -c | tail -20
Or simpler — count requests from CDN ranges versus non-CDN ranges:
# Count today's hits coming from CDN edge ranges vs direct
awk -v date="$(date '+%d/%b/%Y')" '$0 ~ date' /var/log/nginx/access.log \
| wc -l
# Then compare to the CDN dashboard's "requests" figure for the same window
If CDN serves 1M requests/day and origin sees 200k, you’re at 80% offload. With origin shield correctly configured, you should be at 98%+.
Check whether tiered cache / shield is active on a per-request basis.
For Cloudflare:
curl -sI https://www.example.com/some-rarely-visited-post/ \
| grep -i cf-cache-status
# Look for: cf-cache-status: HIT (from PoP)
# Or: cf-cache-status: MISS (PoP miss, shield hit)
# Trace: add ?cf_trace=1 if Argo / Smart Tiered Cache is enabled
For Fastly, the Fastly-Debug-Path header (when Fastly-Debug: 1 is sent) shows the routing path including any shield:
curl -sI -H "Fastly-Debug: 1" https://www.example.com/ \
| grep -i fastly
For CloudFront with Origin Shield, check the X-Cache header. A cache hit from a non-shield POP that originated from the shield will show Hit from cloudfront with a X-Amz-Cf-Pop indicating the edge POP, while origin requests will show Miss from cloudfront.
Measure shield hit ratio specifically (not just edge hit ratio). Most CDN dashboards expose this as “tier 1 hit ratio” or “origin shield hit ratio”:
Edge cache hit ratio: 88%
Origin shield hit ratio: 95% of the 12% that miss edge
Effective origin offload: 88% + (12% × 95%) = 99.4%
That’s the target. If shield hit ratio is below 80%, your shield isn’t actually consolidating misses — either the cache key is fragmenting or the shield TTL is too short.
The fix
Cloudflare Tiered Cache (Pro plan and above)
Tiered cache is a dashboard toggle but the gotcha is that it interacts with APO. If APO is on, tiered cache applies to the assets layer; APO has its own KV-backed tier for HTML.
# Via the API
ZONE_ID="<zone-id>"
CF_TOKEN="<api-token>"
# Enable Smart Tiered Cache (picks shield automatically via Argo)
curl -sX PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/argo/tiered_caching" \
-H "Authorization: Bearer $CF_TOKEN" \
-H "Content-Type: application/json" \
-d '{"value": "on"}'
# Optional — turn on Tiered Cache Topology (Enterprise) for regional shields
curl -sX PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/cache/tiered_cache_smart_topology_enable" \
-H "Authorization: Bearer $CF_TOKEN" \
-H "Content-Type: application/json" \
-d '{"value": "on"}'
Verify it’s on by re-running the verification curl — cf-cache-status should report HIT more often at PoPs that previously had cold caches.
Fastly Origin Shield
Pick one POP close to origin and assign it as the shield for your service. Fastly’s VCL exposes the shield setting per backend.
backend wp_origin {
.host = "origin.example.com";
.port = "443";
.ssl = true;
.shield = "ams-nl"; # Shield POP — pick by latency to origin
.first_byte_timeout = 30s;
.connect_timeout = 2s;
.between_bytes_timeout = 10s;
}
Or via the API:
FASTLY_TOKEN="<token>"
SERVICE_ID="<service-id>"
VERSION=$(curl -sH "Fastly-Key: $FASTLY_TOKEN" \
https://api.fastly.com/service/$SERVICE_ID | jq '.versions[-1].number')
curl -sX PUT "https://api.fastly.com/service/$SERVICE_ID/version/$VERSION/backend/wp_origin" \
-H "Fastly-Key: $FASTLY_TOKEN" \
-d "shield=ams-nl"
Pick the shield POP by measuring latency from each Fastly POP to origin (mtr or tcptraceroute from a small instance per region). Closest POP to origin is usually the right choice — it minimizes shield-to-origin round-trip.
CloudFront Origin Shield
Enable Origin Shield in the origin’s settings within the distribution. Pick the AWS region closest to origin:
# Via AWS CLI
aws cloudfront get-distribution-config --id E1234567890 > dist.json
# Edit dist.json:
# .DistributionConfig.Origins.Items[0].OriginShield = {
# "Enabled": true,
# "OriginShieldRegion": "us-east-1"
# }
aws cloudfront update-distribution \
--id E1234567890 \
--distribution-config file://dist.json \
--if-match <ETag-from-previous-call>
For WordPress origins in EU, prefer eu-west-1 (Ireland) or eu-central-1 (Frankfurt). For US origins, us-east-1 or us-west-2. The AWS pricing for shield is per-request — small relative to the request volume saved at origin, but real.
BunnyCDN Main PoP
ACCOUNT_KEY="<key>"
ZONE_ID=12345
# Enable origin shield, pointing to FRA (frankfurt)
curl -sX POST -H "AccessKey: $ACCOUNT_KEY" -H "Content-Type: application/json" \
-d '{
"EnableOriginShield": true,
"OriginShieldZoneCode": "DE",
"OriginShieldEnableConcurrencyLimit": true,
"OriginShieldMaxConcurrentRequests": 50
}' \
https://api.bunny.net/pullzone/$ZONE_ID
OriginShieldMaxConcurrentRequests is a thundering-herd defense — if a popular URL expires and 200 edge PoPs all try to revalidate at once, only 50 of those requests reach origin. The others wait for the shield to populate.
KeyCDN — separate caching proxy
KeyCDN does not offer origin shield natively. To get the effect, put a small varnish or nginx-with-proxy-cache instance in front of origin and configure KeyCDN’s pull zone to use that instance as origin:
# /etc/nginx/conf.d/shield.conf
proxy_cache_path /var/cache/nginx-shield levels=1:2
keys_zone=shield:100m
max_size=5g inactive=24h use_temp_path=off;
server {
listen 443 ssl http2;
server_name shield.example.com;
location / {
proxy_pass http://127.0.0.1:8080; # actual WP origin on loopback
proxy_cache shield;
proxy_cache_key "$scheme$host$request_uri";
proxy_cache_valid 200 301 302 1h;
proxy_cache_valid 404 1m;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_lock on;
proxy_cache_lock_timeout 5s;
add_header X-Shield-Cache $upstream_cache_status;
}
}
proxy_cache_lock on is the critical piece — it serializes concurrent misses for the same key. One request fetches from origin; others wait for that response and reuse it. This is the origin shield’s core behavior.
Then point KeyCDN’s pull zone at shield.example.com instead of origin.example.com.
Hit ratio targets
After running for 48 hours with shield configured correctly, expect:
- Edge cache hit ratio: 88-95% for HTML, 97-99% for static assets.
- Shield hit ratio (of the edge misses): 85-95%.
- Effective origin offload: 98-99.5%.
- Origin requests per day: should drop by roughly an order of magnitude versus the pre-shield baseline. If it doesn’t, the cache key is fragmenting somewhere — re-run the cookie audit from the other CDN articles in this batch.
If your origin still spikes on popular URLs, add proxy_cache_lock-style request coalescing in front of origin even with the CDN’s native shield enabled. Defense in depth.
Stack Harbor sizes origin shield strategy as part of Enterprise WordPress operations — including the request coalescing layer and the per-CDN shield region selection. If your origin is still buckling under spikes despite a CDN sitting in front, request an architecture review.