Behind the URL: A Field Guide to What Your Image CDN Actually Does With Your Pixels
Photo: Ana Las Heras, CC BY-SA 4.0, via Wikimedia Commons
Most of us treat image CDNs like vending machines: put in a URL, get out a picture. It works, so we stop asking questions. But every image request triggers a cascade of automated decisions — about format, size, quality, and caching — that directly shape your site's performance. And if you've never looked behind the curtain, some of those decisions may surprise you.
Here's the full journey, step by step.
Step One: The Request Hits the Edge
When a user's browser asks for your image, the request doesn't travel to your origin server. It lands on an edge node — a server physically close to the user, likely in a data center in or near their city. If this edge has seen this exact request before, it may serve a cached copy and be done in milliseconds.
Key detail: the "exact request" usually includes the full URL, headers, and sometimes the Accept header. That last one matters more than most developers realize, because it's how the CDN decides which format to send.
Step Two: Format Negotiation
Modern browsers announce what they support via the Accept header — Chrome will happily take AVIF and WebP, Safari prefers WebP and JPEG, older clients just want a JPEG. The CDN reads this and picks the best format it can serve.
This is where things get interesting. Some CDNs encode AVIF aggressively by default; others fall back to WebP silently; some serve whatever your original upload was if they haven't processed it yet. That last case is the sneaky one: the same URL can return a 400KB JPEG for one user and a 90KB AVIF for another, depending on cache state.
Step Three: Transformation (or Not)
If the requested variant doesn't exist yet — say, a 640px-wide WebP at quality 70 — the edge triggers a transformation. The original is fetched from origin or long-term storage, resized, re-encoded, and written back into the cache.
The first user to request a variant pays the generation cost: a slower response, sometimes several seconds. Everyone after that gets the fast path. This is why a freshly deployed site often feels sluggish on images even though "the CDN is on" — the cache is cold, and someone has to warm it.
Step Four: Delivery and Cache Headers
The transformed image is sent back with cache headers that determine how long it lives in browser caches and intermediate proxies. If your CDN's defaults are conservative, users re-download images they already have. If they're aggressive, you might struggle to push updates when someone swaps a hero photo.
Auditing What You're Actually Serving
Reading the docs tells you what the CDN can do. To find out what it's doing, do this:
- Open DevTools' Network tab, filter by images, and look at the
Content-TypeandContent-Lengthcolumns. You'd be surprised how often the answer is "a 600KB JPEG where an AVIF should be." - Compare the served dimensions to the rendered dimensions. The
imgelement's natural size versus its on-screen size tells you instantly if you're shipping oversized assets. - Test with different
Acceptheaders.curl -H "Accept: image/avif,image/webp,*/*" -I your-image-urlversus a plain request reveals whether format negotiation is working or silently broken. - Check the
Cache-ControlandAgeheaders.Age: 0on a popular image suggests your cache keys are too specific or your TTLs too short. - Purge and re-request. Watch the first response time versus the second. If the cold fetch takes multiple seconds, consider pre-generating your most important variants at deploy time.
The Takeaway
An image CDN is genuinely useful infrastructure — but "we use a CDN" is not a performance strategy. The difference between a well-configured one and a default-configured one is often the difference between a 200KB page weight and a 2MB one.
Thirty minutes in the Network tab will tell you which side of that line you're on. Your users, especially the ones on metered connections, will feel the difference every single day.