How to Choose a CDN That Actually Helps Your Site

To choose a CDN, work out three things first: where your users are, how much of your response is cacheable, and what your origin does when it is hit from many places at once. If those three answers point to a CDN, the choice of which one to use becomes much narrower. This article gives you a framework for how to choose a CDN that actually helps, rather than one that adds a hop and a bill.

Start with the cacheability of your content

A CDN is a network of reverse proxies that sit between your users and your origin. It only helps when it can answer a request without going back to your origin. So the first question is not which provider to pick, it is how much of your traffic can be served from a cache at all.

Look at the response headers your origin sends today. The relevant ones are Cache-Control, Vary, Set-Cookie and, for older stacks, Expires. Run something like this against a representative page:

curl -sSI https://www.example.com/static/app.js | grep -iE 'cache-control|vary|set-cookie|etag|age'
cache-control: public, max-age=31536000, immutable
etag: "5f2c9a"

Static assets such as JavaScript, CSS, fonts and images are easy. Give them a long max-age, a content hash in the filename, and immutable, and they will sit in edge caches for a very long time. HTML is harder. If your pages are personalised, or set cookies on every response, a shared cache will either refuse to store them or serve the wrong thing. Check whether your HTML responses carry Cache-Control: private or a Set-Cookie header. If they do, the CDN will mostly be a TLS terminator and a TCP accelerator for you, which is still useful but a different value proposition.

Count the bytes. If the large majority of your transferred bytes are static assets, a CDN will do real work. If most of your bytes are unique HTML and API responses, a CDN helps less with bandwidth and more with connection setup time and routing.

Map your audience before you map your edges

Geography decides whether a CDN helps at all. If your users are in the same region as your origin, a CDN mostly adds a short extra hop. If they are spread across continents, the win comes from two things: terminating TLS close to the user, and serving cached bytes without a transatlantic round trip.

You can measure the baseline yourself. Pick a handful of locations that represent your real audience and compare time to first byte from each. A simple approach is to run the same request from machines you control in different regions, or use a third party measurement service and read the per region breakdown. What you are looking for is the gap between the closest and the furthest user. If the gap is large, a CDN with points of presence near the far users will close it. If the gap is small, the CDN's benefit is mostly in absorbing traffic spikes and shielding the origin.

Ask the provider, or read their public network page, for a list of regions where they have presence. Do not take marketing language at face value. Look for specific city or region names and check them against your own analytics. If your users are concentrated in places the CDN does not serve from, you are paying for a network you will not use.

How to choose a CDN that fits your hosting setup

The origin matters as much as the edge. A CDN works by making requests to your origin on cache misses. That means your origin needs to handle the pattern of traffic the CDN produces: many connections from a smaller set of IP ranges, sometimes in bursts, and with a different Host header than your users send.

If your origin is behind a shared host or a platform that only accepts traffic for a specific hostname, you need the CDN to preserve the original Host header, or to be told which hostname to use when it connects upstream. Most CDNs expose this as an origin configuration option. In a typical configuration file it looks like this:

origin:
  address: origin.example.com
  host_header: www.example.com
  tls: true
  connect_timeout: 5s
cache:
  default_ttl: 300
  respect_origin_headers: true

The exact syntax differs between products, but the concepts do not. You need to know how the CDN identifies your origin, whether it validates the origin's certificate, and whether it will follow redirects. If your origin redirects http to https, and the CDN connects over http, you can create a loop that only shows up under load. Test the origin configuration with a request that forces a cache miss, such as a query string the CDN has never seen:

curl -sSI 'https://cdn.example.net/app.js?cachebust=1' | grep -iE 'x-cache|age|server'
x-cache: MISS
age: 0

Run it twice. The second response should show a hit, or at least an age greater than zero. If it does not, your cache key or your origin headers are wrong, and no amount of extra edge locations will fix it.

What to check in the control plane

Once the basics work, the differences between CDNs are mostly in the control plane: how you purge, how you configure rules, and how much visibility you get. Purge matters more than people expect. If you deploy often, you want a purge that is fast and targeted, ideally by URL or by tag, rather than a global flush that empties every edge at once. Check whether the purge API returns before or after the purge has propagated, and how long propagation takes.

Rules and routing are the next thing to inspect. You will want to vary cache behaviour by path: long TTLs for /static/, short or no caching for /api/, and something in between for HTML. Look at whether the configuration language is expressive enough for your needs without becoming a programming language of its own. A CDN whose rules you cannot reason about is a liability during an incident.

Finally, look at logging and metrics. You want per status code counts, cache hit ratio, origin response time, and the ability to see individual requests when something goes wrong. If the only data available is a monthly summary, you will be blind when it matters. Ask for a sample log line and check what fields it contains before you commit.

Decide, then verify

The durable framework is this: measure cacheability, map audience geography, confirm your origin can take the traffic pattern, and only then compare control plane features. If cacheable bytes are a small share of your traffic and your users are close to your origin, a CDN may not be worth the complexity. If they are far away and most of your bytes are static, almost any competent CDN will help, and the decision comes down to purge, rules and logs.

Before you migrate, put a single low risk path behind the CDN and compare hit ratio and time to first byte against the direct origin. Keep the origin reachable so you can fall back. If the numbers do not improve, or the operational overhead is higher than the benefit, turn it off. The right answer is the one your own measurements support, not the one with the longest feature list.

Related articles

Subscribe to our newsletter

Get the latest hosting tips, performance insights, and industry news.