CDN Cache Tuning
Cache hit rate.
Overview
CDN cache tuning maximises hit rate while preserving freshness. Enabling the CDN gets you a cache; tuning gets you the actual cost and performance benefit.
- Cache hit rate. The headline metric. Every tuning decision is measured against its effect on the hit ratio.
- Cache-Control headers. Per-asset directives drive cache behaviour:
public,max-age,immutablefor static; tighter rules for dynamic. - Vary header awareness. Vary on Accept-Encoding, Accept-Language, but not on User-Agent unless required. Wide Vary kills the hit rate.
- Per-path rules plus origin shield. Each path gets its own cache strategy; origin shield concentrates the cache in front of origin for fewer cache fills.
The approach
Three habits keep CDN caching efficient: get Cache-Control right per asset, monitor the hit rate as a standing signal, and use origin shield to reduce origin load.
- Cache-Control correct per asset. Static assets get long max-age plus immutable; HTML gets short max-age; API responses get private no-store.
- Monitor hit rate per asset class. Headline rate hides the weak spots. Track per asset class to find the cause.
- Origin shield. Single regional cache absorbs cache-miss traffic. Origin sees fewer cold-miss requests.
- Invalidation strategy plus documented policy. Per-asset invalidation pattern (purge, version, signed URL); per-path policy lives in the runbook.
Why this compounds
Each tuned asset produces ongoing performance and cost benefit. The team learns the cache through measurement and new assets ship right-tuned from day one.
- Lower latency. High hit rate produces fast users. The benefit shows up directly in RUM data.
- Lower origin cost. Cache hits reduce origin compute and egress. The savings continue every month.
- Better resilience. Cached origin survives brief outages. The cache absorbs short-term origin trouble.
- Year-one investment, year-two habit. The first tuning is heavy lift. By year two, every new asset ships with cache directives that match the access pattern.