CDN
A CDN serves content from edge locations to reduce latency and improve caching. It's important for global SEO and Core Web Vitals.
Definition
A CDN distributes content via global edge locations to reduce latency and improve reliability. For SEO, it helps improve TTFB/LCP, increases availability, and reduces origin load during traffic spikes and crawling.
Why it matters
- Dramatically reduces global TTFB — users connect to nearest edge, latency drops from 500ms to 50ms
- Improves LCP and Core Web Vitals — faster resource delivery means higher Google scores
- Absorbs traffic spikes — protects origin from crashing during viral events or campaigns
- Improves crawler efficiency — Googlebot doesn't overload origin, crawl budget stays healthy
- DDoS protection — edge network absorbs malicious traffic, origin stays safe
- SSL/TLS termination — edge handles encryption, reducing origin CPU load
- Reduces bandwidth costs — cache hits don't consume origin bandwidth, significant long-term savings
How to implement
- Choose appropriate CDN (Cloudflare, Fastly, AWS CloudFront, Vercel Edge)
- Configure correct caching: long cache for static assets, SWR or short TTL for HTML
- Enable automatic compression (gzip/Brotli) to reduce transfer size
- Set Cache-Control and s-maxage to manage CDN and browser cache separately
- Monitor Cache Hit Ratio — target > 90%
- Set up purge/invalidate mechanism to clear old cache when content updates
- Use Real User Monitoring (RUM) to track actual user TTFB and LCP
Examples
text
# Cloudflare Pages has CDN built-in
# Just configure caching in public/_headers
# public/_headers
/*
Cache-Control: public, max-age=0, must-revalidate
X-Robots-Tag: all
/assets/*
Cache-Control: public, max-age=31536000, immutable
# wrangler.toml (optional: set cache TTL)
[vars]
ASSETS_BROWSER_TTL = 31536000
# Verify CDN caching (curl)
curl -I https://your-site.pages.dev/assets/bundle.js
# Look for cf-cache-status: HIT to confirm cache hitjson
// CloudFront Distribution config summary
{
"Origins": [{
"DomainName": "your-origin.example.com",
"OriginProtocolPolicy": "https-only"
}],
"DefaultCacheBehavior": {
"ViewerProtocolPolicy": "redirect-to-https",
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
// CachingOptimized policy: TTL 86400s, gzip/br enabled
"Compress": true
},
"PriceClass": "PriceClass_100",
// Use only NA+EU edge locations (lower cost)
"HttpVersion": "http2and3"
}FAQ
Common questions about this term.