CloudFront cache hit rate: how it changes origin egress cost
CDN pricing is usually dominated by edge bandwidth and requests, but origin egress can become a major hidden line item. Cache hit rate is the primary knob that changes how much traffic reaches your origin.
Definitions (what "hit rate" means)
- Cache hit: request served from an edge cache without going to the origin.
- Cache miss: request goes to the origin (and often fills the cache).
- Hit rate: hits / (hits + misses) over a time window.
A simple cost model (good for budgeting)
Start with your expected edge traffic and an assumed hit rate H (e.g., 0.85).
- Origin requests/month ~= edge requests/month * (1 - H)
- Origin egress GB/month ~= edge bandwidth GB/month * (1 - H)
This is a baseline. Short TTLs, invalidations, and multi-region fills can increase origin traffic beyond the simple (1 - H) factor.
What breaks cache hit rate (and raises origin cost)
- Cache fragmentation: forwarding many query strings, cookies, or headers creates many cache keys.
- Short TTLs: frequent revalidation forces more origin requests.
- Frequent invalidations: purging popular content reduces hits during deploy windows.
- Uncacheable responses: missing or restrictive Cache-Control headers.
- Cache fills: when the same object is fetched by many edge locations, a single miss can become multiple origin fetches (especially right after deploys).
How to improve hit rate safely
- Use versioned asset URLs (content-hashed filenames) so you rarely need invalidations.
- Normalize cache keys: only include the query params/cookies/headers that truly change responses.
- Set intentional TTLs: long TTL for static assets; shorter TTL for HTML; avoid "0 by default".
- Separate dynamic endpoints: keep truly dynamic, personalized endpoints out of the cache path.
- Use Origin Shield (when appropriate): reduces multi-POP cache fill by centralizing origin fetches.
Worked example (sanity check)
If your CDN serves 10,000 GB/month at the edge:
- At 90% hit rate: origin egress ~= 10,000 GB * (1 - 0.90) ~= 1,000 GB/month
- At 70% hit rate: origin egress ~= 10,000 GB * (1 - 0.70) ~= 3,000 GB/month
A temporary hit rate drop during deployments can show up as a visible origin egress spike, even if edge bandwidth is unchanged.
Cache key checklist (avoid fragmentation)
- Only forward query params that change the response.
- Only forward cookies that change the response (auth cookies often make responses uncacheable).
- Only vary on headers you need; avoid varying on large or unstable headers.
- Confirm caching behavior for 200s and for common 4xx/5xx responses.
Measure and validate
- Measure hit rate on a real distribution, not a single endpoint or a single day.
- Track both edge bytes and origin bytes to validate the origin reduction assumption.
- Validate whether compression changes "bytes at edge" vs "bytes at origin".
- Validate origin request spikes during deploy windows and invalidations.
Related tools
CloudFront cost calculator Origin egress cost Invalidation pricing
Sources
- CloudFront caching: docs.aws.amazon.com
- CloudFront metrics: docs.aws.amazon.com
Related guides
API Gateway vs ALB vs CloudFront cost: what to compare (requests, transfer, add-ons)
A practical cost comparison of API Gateway, Application Load Balancer (ALB), and CloudFront. Compare request pricing, data transfer, caching impact, WAF, logs, and the hidden line items that change the answer.
CloudFront pricing: estimate bandwidth and request costs (without hardcoding prices)
A practical way to estimate CloudFront-style CDN costs using your own bandwidth ($/GB) and request-fee ($ per 10k/1M) assumptions, plus common pitfalls like tiered pricing and origin egress.
Cloud CDN pricing (GCP): bandwidth, requests, and origin egress (cache fill)
A practical Cloud CDN cost model: edge bandwidth, request volume, and origin egress (cache fill). Includes validation steps for hit rate by path, heavy-tail endpoints, and purge/deploy events that reduce hit rate.
CloudFront vs Cloudflare CDN cost: compare the right line items (bandwidth, requests, origin egress)
A practical comparison checklist for CloudFront vs Cloudflare pricing. Compare bandwidth ($/GB), request fees, region mix, origin egress (cache fill), and add-ons like WAF, logs, and edge compute. Includes a modeling template and validation steps.
S3 pricing: a practical model for storage, requests, egress, and replication
A practical S3 pricing guide: what to include (GB-month, requests, egress, replication) and how to estimate the key inputs without copying price tables.
API Gateway cost optimization: reduce requests, bytes, and log spend
A practical playbook to reduce API Gateway spend: identify the dominant driver (requests, transfer, or logs), then apply high-leverage fixes with a validation checklist.
Related calculators
CDN Cost Calculator
Estimate total CDN cost from bandwidth and request pricing.
CDN Bandwidth Cost Calculator
Estimate monthly CDN bandwidth cost from GB transferred and $/GB pricing.
CDN Request Cost Calculator
Estimate CDN request fees from monthly requests and $ per 10k/1M pricing.
Data Egress Cost Calculator
Estimate monthly egress spend from GB transferred and $/GB pricing.
API Response Size Transfer Calculator
Estimate monthly transfer from request volume and average response size.
VPC Data Transfer Cost Calculator
Estimate data transfer spend from GB/month and $/GB assumptions.
FAQ
Why does cache hit rate matter for cost?
Because cache misses become origin requests and origin bytes. Even if CDN bandwidth is fixed, a low hit rate can increase origin egress and origin compute costs.
What usually lowers hit rate the most?
Short TTLs, frequent invalidations, and cache fragmentation from query strings, cookies, or varying headers.
Is the simple hit-rate model exact?
No, but it is a good budgeting baseline. Real systems have TTL expiry, invalidations, multi-POP fills, and compression differences that can move the number.
Last updated: 2026-01-27