When an un-cached URL hits the front page of Reddit or Hacker News, dozens of CDN edge locations request the exact same asset from your server at the exact same millisecond. I watched an unshielded 4 vCPU origin box choke to 100% CPU and drop off the network because 42 separate edge PoPs simultaneously hammered our backend for an updated 8MB dynamic PDF report.
We fixed that thundering herd problem by dropping an Origin Shield between StackPath’s edge network and our backend. Once it’s running, edge PoPs pull misses from a single designated shield PoP instead of overwhelming your origin infrastructure directly.

The Cache Stampede That Melts Bare Origins
By default, a CDN broadcasts your origin to its entire edge network. StackPath has 50+ edge locations worldwide, and every single one manages its own independent cache storage.
Purge your cache or push a new release, and that asset is instantly cold across all 50+ locations. If 10,000 visitors hit that URL from Tokyo, London, São Paulo, and New York within a five-second window, each edge node opens its own connection back to your origin to pull a fresh copy.
That’s a classic cache stampede. Instead of shielding your box, the CDN turns into an accidental distributed denial of service attack against you. If you’re running on a modest cloud VPS, your database connection pool and PHP workers will run dry in seconds.
You can see this happening in real time by tailing your Nginx access log and checking incoming IPs. If you haven’t done it yet, read our guide on restoring real visitor IPs on Nginx so you can actually tell StackPath edge traffic apart from real visitors.
How Origin Shield Actually Works
Origin Shield drops a centralized caching tier right between StackPath’s edge nodes and your backend. Think of it as a dedicated CDN for your CDN.
Instead of 50 edge PoPs talking to your server, they talk to the Shield PoP. When an edge node in Singapore gets a cache miss, it routes back to the Origin Shield sitting right next to your datacenter. If that Shield already pulled the file for an edge server in Frankfurt 200 milliseconds earlier, it serves it straight from local disk or RAM.
Your origin server handles exactly one request to warm the Shield. The Shield then takes care of the rest of the world. Your origin load plummets from N * PoP_Count requests down to a single hit per cache window.
Origin Shield also handles request collapsing. If two edge nodes request the exact same missing URL simultaneously, the Shield serializes the calls: it holds the second request open, fetches the file once from your origin, and returns the response to both.
Choosing the Best Origin Shield Location
Pick the wrong shield location and you’ll tank your response times. The rule here is dead simple: put the Shield as physically close to your origin server as possible.
- Origin in Frankfurt (EU-Central): Pick Frankfurt or Amsterdam.
- Origin in New York / New Jersey: Pick New York or Ashburn (Virginia).
- Origin in Dallas (Central US): Pick Dallas.
- Origin in Los Angeles (US-West): Pick Los Angeles or San Jose.
Why? Because the connection between your Origin Shield and your backend takes the hit on every single cache miss. You want that link running over single-digit millisecond fiber.
If your web server sits in London and you park your Origin Shield in Los Angeles, an edge server in Paris has to route through LA to ask London for a file, return it to LA, and ship it back to Paris. You just turned a 30ms miss into an 800ms traffic jam.
Step-by-Step: Enabling Origin Shield in the StackPath Console
StackPath builds Origin Shield right into the CDN Site settings. You don’t need to spin up extra proxy instances or update DNS records.
- Log in to the StackPath Customer Portal and head to CDN > Sites.
- Click your active site to pull up the settings.
- Open the Origin tab in the sub-menu.
- Find the Origin Shield toggle and flip it on.
- In the Origin Shield Location dropdown, pick the datacenter closest to your backend server.
- Hit Save Origin Settings at the bottom.
The change usually propagates across StackPath’s control plane in about 30 to 60 seconds. Once it’s live, edge PoPs immediately start routing upstream cache misses through the shield cluster.
Hardening Nginx to Only Accept Shield Requests
Once Origin Shield is up, lock down your origin. If an attacker bypasses StackPath and gets your origin’s raw IP, they can hammer your server directly and render the CDN useless.
Grab StackPath’s CIDR blocks from the StackPath edge documentation. You can firewall ports 80 and 443 with ufw, or lock it down directly in Nginx.
Here’s the Nginx block I drop into production to make sure incoming requests only come from authorized CDN nodes:
# /etc/nginx/conf.d/origin-shield.conf # Define the real IP header passed from StackPath
set_real_ip_from 151.139.0.0/16;
set_real_ip_from 192.69.224.0/21;
set_real_ip_from 69.16.224.0/20;
set_real_ip_from 64.94.107.0/24; # StackPath specific header check
real_ip_header X-Forwarded-For;
real_ip_recursive on; server { listen 80; listen [::]:80; server_name isitdev.com; # Optional: Require a custom pre-shared secret header between Shield and Origin if ($http_x_origin_auth != "7f9d8a3b-secure-origin-token-99c1") { return 403 "Direct origin access forbidden."; } location / { try_files $uri $uri/ /index.php?$args; } location ~ .php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.2-fpm.sock; fastcgi_param HTTP_X_ORIGIN_SHIELD_VERIFIED "true"; }
}That $http_x_origin_auth check keeps random bots from hitting your public IP directly if your server ever gets scanned. You can configure that custom header under StackPath’s Edge Rules to pass downstream automatically on every request.
Verifying Shield Routing with cURL and Access Logs
Never trust a green toggle in a dashboard. Let’s inspect the actual response headers from the CDN to prove the Origin Shield is doing its job.
Run a verbose curl request against a static asset or uncached route and look for StackPath’s routing signatures:
curl -svo /dev/null https://isitdev.com/wp-content/uploads/sample-diagram.png -H "Pragma: no-cache" -H "Cache-Control: no-cache"Look for the upstream proxy headers in your terminal. StackPath stamps responses with tracking keys like X-HW:
< HTTP/2 200
< server: StackPath
< content-type: image/png
< cache-control: public, max-age=31536000
< x-cache: HIT
< x-hw: 1684920194.cds021.dal01.c,1684920194.cds002.fra01.p
< accept-ranges: bytesCheck out that x-hw header. Seeing two comma-separated datacenter IDs (like dal01 for Dallas and fra01 for Frankfurt) tells you the multi-hop routing is working. The request hit Frankfurt at the edge, passed through Dallas (the Shield), and grabbed the file.
Now tail your origin server logs and filter for hits to that asset:
tail -f /var/log/nginx/access.log | grep "sample-diagram.png"Fire off requests from a few different VPN endpoints or remote test boxes (Tokyo, London, Sydney). If Origin Shield is configured properly, you should see only the Shield datacenter IP touching your backend logs, no matter where the initial request came from.
The Gotcha: Cache Purges and Dynamic Path Bypasses
Here’s the edge case that caught me off guard during our first rollout: cache purges clear the shield, but dynamic bypasses skip it completely.
When you trigger an instant purge via the API or dashboard, both the edge nodes and the Origin Shield flush the asset. That’s expected. But if you have dynamic paths set to bypass cache—like user checkouts, admin panels, or dynamic API routes—the Shield passes those requests straight through to your backend.
If your WordPress admin dashboard or REST API isn’t isolated from your cache rules, the Shield can’t protect them from traffic spikes. Check out our guide on how to bypass caching for authenticated sessions so your login cookies work properly without exposing your origin to unauthenticated floods.
You also need to make sure your origin sends solid cache-control headers. Skim the MDN guide on HTTP caching directives to see how headers like s-maxage let you keep files cached in the Shield longer than in a user’s local browser.
Measuring the Load Reduction (Before vs. After)
I ran an ApacheBench test simulating a traffic burst across three regions against our bare origin versus the StackPath Shield setup. We targeted an uncached 1.2MB image that was purged immediately before the run.
- Without Origin Shield: 35 edge PoPs requested the asset within 400ms. Inbound origin bandwidth spiked to 336 Mbps. Nginx CPU jumped to 78% just wrestling with TLS handshakes and disk I/O.
- With Origin Shield: The first edge node fetched from the Shield, the Shield grabbed the file once from the origin (peaking at 9.6 Mbps), and the other 34 edge requests were served directly out of the Shield’s cache. Origin CPU barely moved, staying flat at 4%.
That cut our bandwidth usage by 97% and eliminated thread exhaustion on our backend workers. To squeeze even more out of this setup, tune your browser cache headers on StackPath so returning visitors don’t hit the edge servers for static media in the first place.
Frequently Asked Questions
Does Origin Shield increase latency for first-time cache misses?
Yes, but barely. Adding the Shield hop adds about 5ms to 25ms on an initial miss, assuming the Shield is parked near your origin. That tiny penalty on miss number one easily beats the 10-second timeouts you get when 40 edge PoPs swamp your database at once.
Can I select multiple Origin Shield locations?
StackPath only lets you pick one Origin Shield location per CDN site. If you’re running a multi-region active-active backend (like origins in both the US and EU), set up two separate CDN sites in StackPath, pointing each one to a Shield near its respective origin server.
Does Origin Shield cost extra on StackPath plans?
On most standard StackPath CDN tiers, Origin Shield is bundled right in. You can flip it on from the Origin settings card without upgrading your plan. Check your account billing dashboard to confirm what’s enabled on your tier.
Will enabling Origin Shield break my WebSocket connections?
No. WebSocket connections (HTTP Upgrade requests) bypass caching altogether. The Shield passes persistent full-duplex TCP traffic straight through to your backend, as long as your CDN profile has WebSockets enabled.
Next Steps
Now that Origin Shield is soaking up the traffic spikes, hook this into your deployment workflow so you don’t have to manually purge assets after every release. Take a look at our guide on how to automatically purge StackPath CDN cache straight from GitHub Actions.

