Skip to main content
Back to Blog
StrategyMarch 20, 20269 min read

Content Delivery Strategy for E-Commerce Sites

Build an effective content delivery strategy for e-commerce sites using CDNs, edge caching, image optimization, and cache invalidation to improve global page load times.

Introduction

Page speed directly impacts e-commerce revenue. Studies consistently show that every 100ms of additional latency costs 1 percent in conversions. For a store doing $10 million annually, that is $100,000 lost per 100ms of delay. A well-designed content delivery strategy ensures that shoppers worldwide experience fast page loads regardless of their geographic location.

This guide covers CDN architecture, edge caching policies, image optimization, and cache invalidation strategies tailored for e-commerce workloads.

CDN Architecture for E-Commerce

A content delivery network places cached copies of your assets at edge locations worldwide. For e-commerce, the CDN should handle:

  • Static assets: CSS, JavaScript, fonts, and media files
  • Product images: The largest payload on most product pages
  • Full-page cache: Entire HTML responses for anonymous visitors
User → CDN Edge (cache hit) → Response in 20-50ms
User → CDN Edge (cache miss) → Origin server → 200-500ms

Popular options include CloudFront, Cloudflare, and Fastly. Each offers different cache control mechanisms and edge compute capabilities.

Cache Headers and Policies

Configure your origin server to send appropriate cache headers:

# Static assets — cache aggressively
location ~* \.(css|js|woff2|png|jpg|webp|avif|svg)$ {
    expires 1y;
    add_header Cache-Control "public, immutable";
    add_header Vary "Accept-Encoding";
}

# Product pages for anonymous users
location /products/ {
    add_header Cache-Control "public, s-maxage=3600, stale-while-revalidate=86400";
    add_header Vary "Cookie";
}

# Cart and checkout — never cache
location ~* /(cart|checkout|customer)/ {
    add_header Cache-Control "private, no-store";
}

The stale-while-revalidate directive is particularly valuable for e-commerce. It serves a stale cached page instantly while fetching a fresh version in the background, ensuring users never wait for cache misses.

Image Optimization Pipeline

Product images typically account for 60-80 percent of page weight. Implement an automated optimization pipeline:

# Convert images to WebP and AVIF at multiple sizes
for img in /var/www/media/catalog/product/*.jpg; do
  cwebp -q 80 "$img" -o "${img%.jpg}.webp"
  avifenc --min 20 --max 40 "$img" "${img%.jpg}.avif"
done

Serve the optimal format using content negotiation:

map $http_accept $webp_suffix {
    default "";
    "~*webp" ".webp";
}

location /media/catalog/ {
    try_files $uri$webp_suffix $uri =404;
}

Cache Invalidation Strategy

Stale product data — wrong prices, out-of-stock items showing as available — damages customer trust. Implement targeted cache invalidation:

  • Price changes: Purge individual product page URLs via CDN API
  • Stock updates: Use short TTLs (5-10 minutes) for inventory-sensitive pages
  • Catalog-wide changes: Purge by cache tag or surrogate key if your CDN supports it
# CloudFront invalidation for specific products
aws cloudfront create-invalidation \
  --distribution-id E1ABCDEF123 \
  --paths "/products/blue-widget" "/products/red-widget"

Measuring Impact

Track these metrics before and after implementing your CDN strategy:

  • Cache hit ratio: Target above 90 percent for static assets
  • Global TTFB: Measure from multiple regions using synthetic monitoring
  • LCP (Largest Contentful Paint): Should be under 2.5 seconds globally
  • Origin offload: Percentage of requests served from cache without hitting origin

For rendering strategy decisions that complement CDN caching, see our guide on Next.js ISR vs SSR. Our architecture planning service includes full CDN and content delivery audits for e-commerce platforms.

A robust content delivery strategy is not optional for e-commerce — it is a revenue driver. Combine aggressive CDN caching, automated image optimization, and smart cache invalidation to deliver fast experiences to customers worldwide while keeping origin server load manageable.

Need help with this?

Our team handles this kind of work daily. Let us take care of your infrastructure.