sellIntegration
timeline

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.

1Request traced end-to-end
330+Edge cities it could land in
6Hops on the journey
1 IPAnycast address, many locations
insights

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.

schemaThe full path, left to right

Nearest edge PoP

1 DNS query

2 Anycast to nearest PoP

3 passes checks

4 MISS goes deeper

5 read or write

6 data back

7 build response

8 response

Browser

DNS lookup

WAF security

Cache

Worker backend

Storage D1 / KV / R2

local_shipping

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.

account_tree

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.

dns

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.

hub

2. Edge PoP

The nearest Cloudflare data center (Point of Presence). Anycast steers your request here so the round trip stays short.

shield

3. WAF

Inspects the request first. Bad traffic (SQL injection, bots, abuse) is blocked or challenged before it can touch anything else.

bolt

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.

code

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.

database

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.

swap_vert

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.

schemaRequest sequence (HIT vs MISS)
"Storage""Worker""Edge PoP""Browser""Storage""Worker""Edge PoP""Browser"WAF checks the requestStore in cache for next timealt[Cache HIT][Cache MISS]GET /page after DNS and AnycastCached response is fastForward the requestRead or write dataResultFresh responseResponse
info

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.

alt_route

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.

schemaDecision points at the edge

yes

no

yes

no

yes

no

Request arrives at edge PoP

WAF: malicious or bot?

Block or challenge

Fresh copy in cache?

Serve cached HIT

Route matches a Worker?

Run Worker code

Fetch from origin

Build response and maybe cache

Return to browser

rocket_launch

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.

construction

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.

place

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.

jsworker.js — where the Worker sits
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;
  },
};
  1. 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.

    bash
    curl -sI https://example.com | grep -i cf-ray
    # cf-ray: 8a1f...-LHR   (LHR = London)
  2. Watch cache HIT vs MISS

    Run it twice. The first call is often MISS; the second is usually HIT, served straight from the edge.

    bash
    curl -sI https://example.com/logo.png | grep -i cf-cache-status
    # cf-cache-status: HIT
  3. Confirm 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.

school

Key terms, explained

dns

DNS

The internet's phone book. It translates a human name (shop.com) into the numeric IP address a computer can actually connect to.

travel_explore

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.

hub

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.

shield

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.

compare_arrows

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.

home_pin

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_and_updates

Tips & gotchas

report

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.