CDN Prefetch and Preload: Anticipating User Needs

· James Thornton · 4 min read

Loading Resources Before They're Needed

The fastest request is one the browser has already completed. Resource hints tell the browser to start loading resources before the normal HTML parsing would discover them. CDNs amplify these techniques by serving prefetched resources from nearby edge caches. For foundational context, read CDN Performance Metrics: What to Measure — FlyFish NWA.

Resource Hint Types

dns-prefetch

Resolve DNS for a domain before it's needed:

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages
Content Delivery Flow — Optimization pipeline from request to responseContent Delivery Flow — Optimization pipeline from request to response CDN Request Flow — From Browser to Edge CDN Request Lifecycle Step 1 DNS Lookup Step 2 TCP Connect Step 3 TLS Handshake Step 4 Edge Server Step 5 Cache Check Step 6 Response Cache HIT → 5ms response Cache MISS → Fetch origin 0ms ~50ms (cache hit) ~200ms (cache miss)
Figure 1: Content Delivery Flow — Optimization pipeline from request to response
<link rel="dns-prefetch" href="https://cdn.example.com">

Saves 20-100ms of DNS lookup time. Use for third-party domains you'll load resources from.

preconnect

Complete DNS + TCP + TLS for a domain:

<link rel="preconnect" href="https://cdn.example.com">
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>

Saves 100-300ms by completing the full connection setup. Use for critical third-party origins. Don't overuse — each preconnect consumes a connection and browser resources.

preload

Fetch a specific resource with high priority:

<link rel="preload" href="/fonts/custom.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/hero-image.webp" as="image">
<link rel="preload" href="/critical.css" as="style">

Preload is for resources needed on the current page that the browser would discover late (fonts in CSS, LCP images, dynamic imports). The as attribute is required — it sets the priority and applies correct CSP.

prefetch

Fetch a resource for future navigation at low priority:

<link rel="prefetch" href="/next-page.html">
<link rel="prefetch" href="/next-page-hero.webp">

Prefetch is for resources on pages the user is likely to visit next. The browser fetches them during idle time. CDN serves from edge cache, making the next page load instant.

CDN-Specific Prefetching

103 Early Hints

CDNs can send 103 status responses with preload hints before the origin has responded. The browser starts fetching resources while waiting for the main response.

Link Header

CDNs can add resource hints via the HTTP Link header (equivalent to <link> in HTML):

Link: </style.css>; rel=preload; as=style, </font.woff2>; rel=preload; as=font; crossorigin

This works even for non-HTML responses (API calls that trigger subsequent resource loads).

Predictive Prefetching

Some CDNs analyze user navigation patterns and automatically prefetch likely next-page resources:

Performance Impact — Measurable improvements from optimizationPerformance Impact — Measurable improvements from optimization CDN Performance Dashboard — Core Web Vitals Core Web Vitals with CDN LCP 1.8s Target: < 2.5s Good FID 45ms Target: < 100ms Good CLS 0.05 Target: < 0.1 Good TTFB 120ms Target: < 800ms Good
Figure 2: Performance Impact — Measurable improvements from optimization
<script type="speculationrules">
{
  "prerender": [
    {"where": {"href_matches": "/products/*"}, "eagerness": "moderate"}
  ]
}
</script>

Best Practices

External References

References & Standards: RFC 7234 · HTTP/2 specification