βΆCDN vendor choice in 2026 β Cloudflare vs Fastly vs CloudFront vs Bunny?
Cloudflare: best all-around, 300+ PoPs, Workers free tier, DDoS included, $20-200/mo. Fastly: edge compute leader, bare-metal for ultra-low latency, expensive ($0.12/req). AWS CloudFront: deepest integration with S3/Lambda, regional discount, pay-per-GB. Bunny.net: best performance-per-dollar ($0.01/GB), no API rate limits, smaller brand. Pick: AWS-native stacks β CloudFront; startups + DX β Cloudflare; performance obsessive β Fastly; price-sensitive β Bunny.
βΆWhen should I use edge compute (Workers/Compute@Edge) vs origin?
Edge compute: A/B testing, image resizing, auth, geo-routing, request rewriting, <100ms operations. NO database queries, file I/O, or >10MB payloads. Origin: business logic, DB calls, complex state. Hybrid: edge handles 80% (cache hits + transformations), origin handles the 20% (cache misses + mutations). Cost: Workers $0.50/1M requests; Compute@Edge $0.12/request is pricey.
βΆCache-Control vs Surrogate-Key vs cache tags β which invalidation strategy?
Cache-Control (public/max-age/s-maxage) is HTTP standard, works everywhere. Surrogate-Key is Fastly/Akamai, allows tag-based instant purge (e.g., purge all posts by author). Cache tags are Cloudflare's version. For content that changes together: use surrogate-key/tags + instant purge. For time-based expiry: Cache-Control s-maxage. Hybrid: s-maxage=86400 (24h default) + surrogate-key=author:123 (purge on update).
βΆImage CDN strategy β separate domain or same CDN?
Separate domain (e.g., cdn.example.com for images, api.example.com for API): cleaner cache isolation, easier resize-on-upload, avoids cookie bloat. Same CDN with path-based routing: simpler ops, one vendor relationship. Modern: Vercel Image Optimization or Cloudflare Image Resizing (on-demand transforms). For high volume: dedicated image CDN (Imgix, Cloudinary) with your CDN in front.
βΆMulti-CDN load balancing β is it worth the complexity?
Yes if: >100k rps, region-specific SLAs, vendor incident risk, negotiating volume discounts. How: GeoDNS (Route53, Dyn) routes to primary/secondary CDNs per region. Or: failover at origin (try Fastly β fallback CloudFront). Overhead: 2-5% extra cost for dual-ingestion, operator complexity. Small-mid companies: stick to one CDN, prioritize cache hit rate.
βΆImage optimization at edge β resize/compress/format in real-time?
YES, if you have 100+ image variants. Tools: Cloudflare Image Resizing ($5/month + compute), Fastly Image Optimizer, AWS Lambda@Edge + Sharp. Workflow: upload original to S3 β querystring params (?w=400&h=300&format=webp) β edge resizes on first request β cache as new variant. Saves 60-80% bandwidth vs serving full-res. Tradeoff: CPU cost + cold-start latency on first resize.
βΆCDN cost optimization β how to not get surprised by the bill?
Set alerts on data transfer. Estimate: 1M users Γ 2MB per visit Γ 0.015/GB (CloudFront) = $30/month. Tactics: (1) Enable compression (gzip/brotli, save 60-70%), (2) Immutable filenames + long max-age (cache hits), (3) Lazy-load images (defer non-critical), (4) Origin shielding (Fastly/CloudFront, reduce 404s from cache misses), (5) Smart TTLs (static: 1yr, HTML: 5min, API: 0min). Monitor hit rates; <70% = misconfigured.