CDN Image Optimization: Format, Size, and Delivery

· Alex Petrov · 4 min read

Why Image Optimization Matters

Images account for 40-60% of total page weight. They're often the LCP element. Optimizing image delivery at the CDN edge is the highest-impact performance improvement for most websites.

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

Format Conversion

Modern image formats deliver the same visual quality at much smaller file sizes: For foundational context, read CDN Performance Metrics: What to Measure — FlyFish NWA.

FormatSize vs JPEGBrowser SupportBest For
JPEGBaselineUniversalPhotographs
WebP25-35% smaller97%+ (all modern browsers)General purpose
AVIF40-50% smaller90%+ (Chrome, Firefox, Safari 16+)Best compression
PNGLargerUniversalTransparency, screenshots

CDN Auto-Format

CDNs can automatically convert images based on the browser's Accept header:

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
# Browser sends:
Accept: image/avif, image/webp, image/*, */*

# CDN serves:
AVIF if browser supports it
WebP if browser supports it but not AVIF
Original format as fallback

This is transparent to your application — you serve /image.jpg and the CDN delivers the optimal format. Requires the CDN to process images, adding the format variant to the cache key.

Responsive Sizing

CDN image services can resize images on the fly:

# Original: 4000×3000 pixels
https://cdn.example.com/photo.jpg?w=800&h=600&fit=cover
https://cdn.example.com/photo.jpg?w=400&h=300&fit=cover
https://cdn.example.com/photo.jpg?w=200&dpr=2

Combined with <picture> or srcset in HTML, the browser requests the size it actually needs instead of downloading a full-resolution image.

Quality Optimization

CDNs can adjust compression quality based on content type and connection speed:

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

Lazy Loading

CDNs can inject loading="lazy" on images below the fold, preventing off-screen images from blocking page load:

<img src="/photo.jpg" width="800" height="600" loading="lazy">

The LCP image must NOT be lazy-loaded — it should use loading="eager" (the default) and be preloaded.

CDN Image Services

Image Caching Strategy

Each image variant (format + size + quality) is a separate cache entry. With 5 sizes × 3 formats = 15 variants per image. Use origin shield to consolidate variant generation — transform once at the shield, serve from edge cache thereafter.

Performance Impact

Typical results from CDN image optimization:

External References

References & Standards: Cloudflare documentation · OWASP CDN Security