CDN performance optimization


A CDN problem is often a revenue problem in disguise: slower image and script delivery increases bounce rate, lowers conversion rate, and makes paid acquisition less efficient – especially for shoppers far from your origin server.

CDN performance optimization means configuring and operating your Content Delivery Network so that the right content is served from the right edge location with minimal connection and transfer overhead. In plain terms: more cache hits, fewer slow origin fetches, and lower latency for every critical byte that affects Core Web Vitals.

What a CDN really improves

A CDN can speed up your site in three main ways:

  1. Serve cached content from an edge location close to the visitor (reducing network latency and round trips).
  2. Reduce connection overhead by terminating TLS near the visitor and reusing connections (impacting DNS lookup time, TLS handshake, and connection reuse).
  3. Protect your origin by absorbing traffic spikes and smoothing load (which reduces slowdowns on cache misses and lowers origin cost).

What a CDN usually does not fix by itself:

The Website Owner's perspective
If your checkout feels sluggish "sometimes," a CDN misconfiguration is a prime suspect – because it creates inconsistent performance by geography, device, cache state, and traffic spikes. Consistency matters as much as raw speed when you're trying to scale paid campaigns or improve SEO.

How CDN performance is measured

"CDN performance" isn't a single standardized metric. In practice, website owners optimize a small set of measurements that explain whether the CDN is doing its job.

The metrics that matter most

1) Edge TTFB (cached vs uncached)
TTFB tells you how quickly the first byte arrives after the request begins. For CDN analysis, always split it into:

  • TTFB on cache HIT: should be low and stable. This reflects edge proximity, routing, and connection overhead.
  • TTFB on cache MISS: includes the origin fetch time, plus any CDN overhead.

2) Cache hit ratio (overall and by path)
A high hit ratio generally means more requests are served from edge quickly and cheaply. But "overall hit ratio" can be misleading if your critical assets (hero image, CSS, main JS bundle) are missing.

3) CDN vs origin latency
You're looking for the split between time spent at the edge versus time spent waiting for your origin. This is the core diagnostic for whether you need CDN changes, origin changes, or both. (Related: CDN vs origin latency.)

4) p75 and p95, not averages
CDNs fail "at the edges": cold cache, less common regions, peak load, or routing changes. Percentiles show that pain clearly.

The basic calculation model (no math needed)

Think of every CDN request like a timeline:

  • Connection setup: DNS → TCP → TLS
  • Request/response latency: round trips and edge processing
  • If cache MISS: edge → origin → edge (origin fetch and waiting)
  • Transfer time: payload size and compression

If you reduce any of those phases – especially the MISS phase for critical assets – your real user speed improves.

Stacked bar chart comparing cache hit and cache miss request phases for TTFB[A cache miss adds origin wait time, which often dominates total latency and turns a fast edge delivery into a slow request.]

The Website Owner's perspective
The biggest "aha" is that CDN optimization isn't only about shaving 30 ms off DNS or TLS. It's about preventing the 500–1,000 ms penalty of an origin fetch on the requests that shape conversion – your LCP image, your CSS, and your primary JS bundles.

What usually breaks CDN speed

Most "our CDN is slow" cases come down to one of these patterns.

Low hit ratio from cache fragmentation

Your CDN might be caching, but not reusing the cache due to cache key variation:

  • Query parameters used for tracking (?utm=...) affecting caching
  • Cookies included in the cache key (common with personalization tools)
  • Overly broad Vary headers (like varying on User-Agent)
  • Multiple hostnames for the same assets (www vs apex, or multiple CDN CNAMEs)
  • Unversioned asset URLs, forcing short TTLs and frequent revalidation

This creates a double hit: fewer cache hits (slower) and higher CDN+origin costs (more expensive).

Related reading that affects this directly:

CDN bypass from "private" responses

Even one header can ruin caching for the assets you care about:

  • Cache-Control: no-store or private on assets that should be public
  • Missing s-maxage on HTML you intended to cache at the edge
  • Cookies being set on static assets (often accidental via middleware)

Slow origin on misses (your CDN is exposing it)

A CDN doesn't eliminate origin work; it reduces how often it happens. If your origin is slow, cache misses become painfully visible.

If miss TTFB is high:

  • Check server response time and TTFB at origin
  • Confirm whether your CDN uses origin shielding/tiered caching (if available)
  • Look for "thundering herd" behavior during cache expiration (many users triggering simultaneous re-fetches)

Connection overhead and routing issues

Even on cache hits, you can see high latency if:

  • DNS is slow (misconfigured DNS, too low TTL, extra lookups)
  • TLS handshakes are frequent (poor keep-alive, no connection reuse)
  • PoP coverage is weak for key markets, or routing isn't optimal
  • HTTP/3 or HTTP/2 behaviors differ by client/network (HTTP/2 performance, HTTP/3 performance)

You can often improve this with preconnect and DNS prefetch for critical third-party origins, and by ensuring your own asset domains are stable and consolidated.

The changes that move the needle most

If you want the biggest real-world gains (and fewer regressions), prioritize in this order.

1) Fix caching headers and TTLs

Start by making cache behavior intentional. For most sites, a practical pattern looks like:

  • Versioned static assets (app.8c1f3.js, styles.a91d.css): cache "forever"
  • Images: long TTL, purge by URL when changed
  • HTML: short TTL (or microcaching), potentially with stale-while-revalidate
  • APIs: usually not cached unless explicitly safe

Here's a baseline you can adapt:

Content typeGoalCommon approachRisk if wrong
Versioned JS/CSSMax cache hitsLong TTL + immutableVery low
FontsFast repeat viewsLong TTL, correct CORSMedium (CORS issues)
Product imagesFast LCPLong TTL, purge on updateStale images
HTML (anon)Reduce TTFBShort TTL + edge cachingStale pricing/stock
HTML (logged-in)CorrectnessBypass cacheNone (but slower)

Where this ties in:

Operational tip: Prefer cache busting via versioned URLs over frequent purges. Purges create cold-cache windows right when you launch campaigns.

2) Normalize the cache key

Your cache key should reflect what truly changes the content – not what happens to be in the URL.

Common improvements:

  • Ignore known marketing query parameters for static assets
  • Separate "anonymous HTML" and "authenticated HTML" with clear rules
  • Reduce or remove unnecessary Vary dimensions

This is where CDN performance optimization becomes a business lever: you're buying reuse, not just bandwidth.

3) Compress and right-size payloads

Even a perfect cache hit can be slow if you're shipping too many bytes.

High-impact areas:

The Website Owner's perspective
A CDN makes it cheap to deliver bytes, but it doesn't make bytes free. If you reduce image weight by 30–60 percent, you often see mobile conversion lift even when TTFB is already "good," because transfer and decoding time still matter for LCP.

4) Reduce render-blocking dependency on slow origins

CDN optimization works best when your critical path depends on assets that are cacheable and edge-served:

This is where CDN and front-end performance meet: if your LCP element is a background image loaded late by JS, the CDN can be perfect and you still lose.

5) Make misses less painful

You'll never get to 100% cache hits. The goal is to make misses rarer – and cheaper.

Practical techniques (provider-dependent):

  • Origin shielding / tiered caching
  • Stale-while-revalidate behavior for HTML and JSON that tolerates brief staleness
  • Request coalescing to prevent stampedes on expiration

Even without advanced features, you can often simulate this by:

  • Extending TTLs for semi-static pages (category pages) during peak season
  • Scheduling cache warmup for key landing pages before major campaigns

Two-panel heatmap showing cache hit ratio by URL group before and after cache key normalization[When cache keys are normalized, hit ratio rises most for high-volume assets, reducing origin load and stabilizing speed across regions.]

How CDN optimization shows up in Core Web Vitals

CDN changes typically affect Web Vitals indirectly – by reducing time spent waiting on the network.

LCP: biggest beneficiary

LCP improves when the browser can fetch the LCP resource quickly:

  • LCP image served from edge with high hit ratio
  • CSS delivered fast so the LCP element can render earlier
  • Lower TTFB so the HTML arrives earlier and resource discovery happens sooner

If you improve edge caching and see TTFB drop but LCP does not, suspect:

  • The LCP resource is not cached (misses)
  • The LCP resource is discovered late (JS-driven rendering)
  • The LCP resource is too heavy (transfer + decode dominates)

FCP and Speed Index

Lower network wait helps FCP and Speed Index, especially on slower mobile networks. But if your main thread is overloaded, you may see less improvement than expected.

INP: usually not a CDN story

INP is dominated by client-side work and long tasks. CDN work can help indirectly (faster JS delivery), but if you're missing INP targets, focus on reduce main thread work and unused JavaScript.

Line chart of p75 LCP by region before and after CDN optimization[CDN wins are often largest outside your origin's region – exactly where global customers feel the most friction.]

How to interpret changes (and avoid false wins)

CDN optimization can produce improvements that look great in a single test but don't hold up in production. Here's how to read the signals.

A drop in cached TTFB is a "real" CDN win

If cache HIT TTFB drops across many geographies, you likely improved:

  • PoP selection/routing
  • DNS/TLS overhead
  • Connection reuse behavior
  • Edge compute overhead

This usually translates to more consistent user experience.

A drop in miss TTFB might be origin work

If only cache MISS TTFB improves, you may have:

  • Improved origin performance
  • Reduced payload size
  • Reduced backend variability
  • Added origin shielding/tiered caching

Still valuable, but it's not the same as edge delivery efficiency.

A higher hit ratio can still hurt if content is wrong

Hit ratio going up is not automatically good if you accidentally cached:

  • Personalized prices
  • Logged-in account pages
  • Geo-specific compliance or shipping content

For safety, explicitly separate:

  • Anonymous cacheable HTML (short TTL, controlled variation)
  • Authenticated bypassed HTML
  • Static immutable assets

The Website Owner's perspective
The best CDN change is the one that improves speed without creating support tickets. Any time you cache HTML more aggressively, plan the rollback: which headers/rules you'll revert, how you'll purge safely, and what "wrong content" would look like for customers.

A practical monitoring checklist

To keep CDN performance from regressing, monitor a small set of indicators continuously.

What to track weekly

  • Cache hit ratio by content type (HTML vs assets vs images)
  • p75 and p95 cached TTFB by region
  • Miss TTFB and origin response time trends
  • Top paths by traffic with lowest hit ratio (the "leaks")

For measurement strategy context, see:

If you use PageVitals, the most relevant views are typically:

Practical benchmarks (rules of thumb)

These vary by geography and audience, but they're useful for decision-making:

  • Cached TTFB: try to keep it consistently under a few hundred milliseconds in your key markets.
  • Static asset hit ratio: aim for 90%+; if you have fully versioned assets, 95%+ is realistic.
  • Image hit ratio: often 90%+ is attainable if URLs are stable and you're not varying by cookies/query strings.
  • HTML hit ratio: depends on personalization. Many stores keep it low intentionally for safety, then focus on caching critical assets.

When to prioritize CDN work vs other work

Use this quick decision table:

SymptomLikely primary bottleneckBest next move
High cached TTFBDNS/TLS/routing/PoPCDN networking and configuration
Low hit ratio on assetsHeaders/cache keyFix Cache-Control and cache key rules
Miss TTFB spikesOrigin latencyImprove origin, add shielding, reduce stampedes
LCP high but TTFB goodPayload/renderingOptimize images, critical path, JS/CSS
INP poorMain threadReduce JS work, long tasks, third parties

A simple rollout plan that avoids regressions

If you want a safe, repeatable approach:

  1. Pick one user-critical path (home → category → product) and identify LCP resources.
  2. Confirm what's served from CDN today and whether it's a cache hit.
  3. Fix headers for immutable assets first (lowest risk, biggest hit ratio gains).
  4. Normalize cache keys (ignore known tracking params, reduce cookie variation).
  5. Only then consider caching HTML for anonymous users with short TTL and careful variation rules.
  6. Validate with field trends (CrUX/RUM), not just a single synthetic run.

This sequencing keeps you from taking on the riskiest caching (HTML) before you've captured the easiest wins (assets, images, compression).


If you want to go deeper on the two biggest levers behind most CDN improvements, start with edge caching and Cache-Control headers. They're the foundation for higher hit ratio, lower TTFB, and more predictable performance as traffic scales.

Frequently asked questions

For most e-commerce sites, aim for 90 percent or higher on truly static assets like images, fonts, and versioned JS and CSS. If hit ratio is lower, you are paying for a CDN but still waiting on origin. Focus first on cache-control headers, query string handling, and cookie bypass rules.

Lab tests often run from a few locations with warmed caches, while real traffic includes many geographies, devices, and cold-cache scenarios. Also, CDNs mostly help network time, not heavy JavaScript or main-thread work. Validate with field data, segment by country, and confirm whether your LCP resources are actually served from edge.

Sometimes, but only when personalization is controlled. If pages vary by cookies, geography, currency, or logged-in state, HTML caching can leak wrong content or destroy hit ratio due to cache fragmentation. A common approach is caching for anonymous users with short TTL and using stale-while-revalidate, while bypassing for authenticated sessions.

For cached responses served from edge, many sites can reach roughly 50 to 200 ms TTFB in the same region and 150 to 400 ms cross-region, depending on RTT and TLS. If cached TTFB is consistently high, look at DNS and TLS handshake time, PoP coverage, and connection reuse.

Switch only after you confirm configuration is not the real issue. If hit ratio is low, or origin is slow on cache misses, another CDN will not fix it. Consider switching when you see persistently high edge TTFB in key markets, weak PoP coverage, missing features you need, or unpredictable performance at peak traffic.