The life of a request on Cloudflare
This is the mental model that ties the whole platform together — once you can draw it, everything else clicks.
What journey are we tracing?
Every time you open a web page, a single HTTP request leaves your browser and travels through a chain of stops before an answer comes back. On Cloudflare that chain is: DNS finds the address, Anycast routes you to the nearest edge data center, the WAF checks the request is safe, the cache tries to answer instantly, and only if needed does a Worker run your back-end code and read storage. Then the response retraces its steps home.
Here is the whole path on one diagram. Read it left to right: the browser starts the trip, the edge PoP does the heavy lifting (WAF then cache then Worker), storage sits at the far end, and the response flows back.
Think of it like a parcel delivery
DNS is looking up the address. Anycast is the courier choosing the nearest depot. The WAF is security at the gate. The cache is a shelf of ready-to-ship parcels. The Worker is the worker who assembles a custom order, and storage is the warehouse out back. Most of the time you never reach the warehouse — the shelf already had your parcel.
Each hop, one at a time
Six stops make up the journey. Each one has a single job, and each one can short-circuit the trip — for example, the cache can answer before the request ever reaches your code.
1. DNS
Turns a name like shop.com into an IP address. On Cloudflare that IP is an Anycast address shared by every edge data center.
2. Edge PoP
The nearest Cloudflare data center (Point of Presence). Anycast steers your request here so the round trip stays short.
3. WAF
Inspects the request first. Bad traffic (SQL injection, bots, abuse) is blocked or challenged before it can touch anything else.
4. Cache
If a fresh copy of the response is already stored at this PoP, it is sent back instantly — a cache HIT. No Worker, no origin.
5. Worker (back-end)
On a cache MISS, your serverless code runs right here at the edge. It decides what to do: read data, call an API, render HTML.
6. Storage
The Worker reads or writes data: D1 (SQL), KV (key-value), or R2 (files). This is the far end of the trip before the answer turns around.
Step by step, with cache HIT vs MISS
Now the same trip as a time-ordered sequence. Notice the branch: a cache HIT answers in one short hop, while a cache MISS has to wake the Worker and reach storage before it can reply — and then it saves the result so the next visitor gets a HIT.
How to tell HIT from MISS
Cloudflare reports the outcome in the cf-cache-status response header. The first request to a page is often a MISS; load it again and you usually get a HIT served straight from the edge.
The decisions made at the edge
Inside that one edge PoP, a few yes/no questions decide the rest of the request's fate: is it malicious, is it already cached, and does a route send it to a Worker? Following the arrows shows every possible path the request can take.
Cheapest path wins
The earlier the request exits this chart, the faster and cheaper it is. A cache HIT skips the Worker, the origin, and storage entirely — which is why caching is the single biggest performance lever you have.
Where the Worker sits in the path
A Worker is just a fetch handler that Cloudflare runs at the edge PoP — after the WAF, and only when the cache could not answer. Here is a sketch that mirrors the diagrams above: try the cache first, run back-end logic and read storage on a MISS, then save the response for next time.
This code runs at step 5
env.DB is a D1 (SQL) binding and env.ASSETS is a KV binding — both are the 'storage' hop. caches.default is the edge cache from the diagrams. ctx.waitUntil lets the response leave while the cache write finishes in the background.
export default {
// Cloudflare runs this at the edge PoP, AFTER the WAF and a cache MISS
async fetch(request, env, ctx) {
const url = new URL(request.url);
// 1) Try the edge cache first
const cache = caches.default;
let response = await cache.match(request);
if (response) {
return response; // cache HIT - the fastest path home
}
// 2) Cache MISS - run back-end logic and read storage
if (url.pathname === "/api/profile") {
const user = await env.DB.prepare(
"SELECT name FROM users WHERE id = ?"
).bind(url.searchParams.get("id")).first();
response = Response.json(user);
} else {
const html = await env.ASSETS.get("index.html");
response = new Response(html, {
headers: { "content-type": "text/html" },
});
}
// 3) Save to the edge cache for the next visitor, then return
response.headers.append("Cache-Control", "max-age=60");
ctx.waitUntil(cache.put(request, response.clone()));
return response;
},
};See which PoP you reached
The cf-ray header ends with a 3-letter airport code — that is the edge data center that served you.
curl -sI https://example.com | grep -i cf-ray # cf-ray: 8a1f...-LHR (LHR = London)Watch cache HIT vs MISS
Run it twice. The first call is often MISS; the second is usually HIT, served straight from the edge.
curl -sI https://example.com/logo.png | grep -i cf-cache-status # cf-cache-status: HITConfirm the Worker ran
Add a custom header in your Worker (for example response.headers.set('x-served-by', 'worker')) and look for it in the response to prove your code was the one that answered.
Key terms, explained
DNS
The internet's phone book. It translates a human name (shop.com) into the numeric IP address a computer can actually connect to.
Anycast
One IP address announced from hundreds of locations at once. The network automatically delivers each request to the closest one, so users always hit a nearby edge.
Edge / PoP
'Edge' means servers near users instead of one faraway data center. A PoP (Point of Presence) is one such location — Cloudflare has them in 330+ cities.
WAF
Web Application Firewall. It inspects each request at the edge and blocks common attacks (SQL injection, XSS) and abusive bots before they reach your app.
Cache HIT / MISS
A HIT means the edge already had a fresh copy and answered instantly. A MISS means it had to go fetch a fresh one (from a Worker or your origin) and then store it.
Origin
Your own server or service that holds the original content. Cloudflare only goes back to the origin when the edge cannot answer from cache or a Worker — that round trip is 'going to origin'.
Tips & gotchas
Never cache per-user pages
If a logged-in dashboard is cached at the edge, one user could be served another user's page. Mark private responses with Cache-Control: private, no-store so they always go through the Worker.
- The whole chain (DNS, edge, WAF, cache) only kicks in when your DNS record is proxied — the orange cloud in the dashboard.
- Static files (images, CSS, JS) cache beautifully; dynamic, personalized responses usually should not.
- A cache HIT never runs your Worker, so it costs no Worker requests and adds no latency.
- cf-ray identifies the PoP and the exact request; keep it when filing a support ticket.
- Read the chapters on DNS, CDN, WAF, and Workers next — each one is a single hop in this diagram.
Related products
menu_bookOfficial docsopen_in_new