CDN Cost Optimization: Reducing Bills Without Sacrificing Performance
CDN costs scale with traffic, and for high-traffic sites, the monthly bill can rival hosting costs. Yet most organizations pay 30–60% more than necessary because they have not optimized their cache configuration, compression settings, or pricing agreements. The good news: CDN cost optimization rarely requires sacrificing performance. In most cases, the changes that reduce costs also improve delivery speed. For a comprehensive overview, see our guide on CDN Monitoring and Observability: Metrics That Matter — FlyFish NWA.
This guide covers every lever you can pull to reduce CDN spending, from quick wins (enabling Brotli compression, fixing cache TTLs) to strategic decisions (committed-use contracts, multi-CDN arbitrage). Each section includes specific dollar-impact estimates so you can prioritize the optimizations that matter most for your traffic profile.
How Do CDN Pricing Models Work?
Before optimizing, you need to understand what you are paying for. CDN pricing has three primary components, and providers weight them differently.
| Provider | Bandwidth (per GB, first 10 TB) | Requests (per 10K) | Notable |
|---|---|---|---|
| Cloudflare | $0 (unlimited) | $0 (unlimited) | All plans include unlimited bandwidth |
| AWS CloudFront | $0.085 | $0.0100 (HTTPS) | Free tier: 1 TB/month |
| Fastly | $0.12 | $0.009 | Real-time log streaming included |
| Akamai | Custom (contract) | Custom | Enterprise-only, volume discounts |
| Bunny CDN | $0.01 | Included | Flat rate, no request fees |
| KeyCDN | $0.04 | Included | Pay-as-you-go, no commitments |
Bandwidth charges are the largest cost driver for most sites. You pay for every byte delivered from the CDN edge to the end user. Origin-to-CDN bandwidth (shield fills, cache misses) may incur separate charges depending on the provider.
Request charges matter for sites with many small files (API-heavy applications, sites with numerous tiny images). At CloudFront's HTTPS rate, 100 million requests per month costs $100—significant for high-request-volume, low-bandwidth applications.
Feature surcharges add up silently: edge functions ($0.50–1.00 per million invocations), image optimization ($0.01–0.03 per transformation), WAF requests ($0.60–1.00 per million inspected), and real-time log delivery ($0.01–0.05 per million log lines). Review your bill line by line.
How Does Improving Cache Hit Ratio Reduce Costs?
Cache hit ratio is the single most impactful cost lever. Every percentage point improvement reduces origin bandwidth, origin compute load, and (for some providers) request-tier pricing.
| Metric | Edge Processing | Origin Processing | Improvement |
|---|---|---|---|
| Latency (p50) | 8–15 ms | 120–300 ms | 15–20x faster |
| Cache Hit Ratio | 85–95% | N/A | Reduces origin load |
| TLS Handshake | 1–5 ms (nearby PoP) | 50–150 ms | 10–30x faster |
| Bandwidth Cost | $0.01–0.04/GB | $0.05–0.12/GB | 3–5x cheaper |
| Availability | 99.99% (multi-PoP) | 99.9% (single DC) | 10x fewer outages |
The math. Consider a site serving 100 TB/month through CloudFront. At a 70% cache hit ratio, 30 TB flows from origin. At a 90% cache hit ratio, only 10 TB flows from origin. That is a 67% reduction in origin egress (which you also pay for at your hosting provider). On the CDN side, cache hits are cheaper to serve (no origin fetch latency or connection overhead).
Quick wins for cache hit improvement:
- Remove unnecessary query parameters from cache keys (analytics tags like utm_source, tracking pixels)
- Normalize URL case (the CDN treats /Page and /page as different cache entries)
- Extend TTLs for truly static content (images, fonts, versioned JS/CSS) to 1 year with immutable
- Use stale-while-revalidate to serve cached content during revalidation
- Implement an origin shield to consolidate cache fills from a single PoP
Each of these is covered in depth in the Cache Hit Ratio Optimization guide. For the underlying cache key mechanics, see Cache Key Design.
How Much Can Compression Save on CDN Bandwidth?
Compression reduces the bytes transferred for text-based content (HTML, CSS, JS, JSON, SVG, XML). The savings are substantial and require minimal configuration.
Brotli vs gzip savings. Brotli at quality 11 compresses 15–25% better than gzip level 6 for typical web content. For a site serving 10 TB/month of compressible content via gzip, switching to Brotli saves 1.5–2.5 TB of bandwidth per month. At $0.08/GB, that is $120–200/month in direct savings. See Brotli and Gzip Compression for implementation details.
Pre-compression for static assets. Configure your build pipeline to generate .br (Brotli) and .gz (gzip) files alongside originals. The CDN serves the pre-compressed file directly without spending CPU on real-time compression. This allows Brotli quality 11 (maximum compression, too slow for real-time) for static assets.
Do not compress already-compressed formats. Images (JPEG, PNG, WebP), videos, fonts (WOFF2), and ZIP files are already compressed. Attempting to gzip them wastes CPU and may actually increase file size. Configure your CDN to skip compression for binary content types.
How Does Image Optimization Impact CDN Costs?
Images are the dominant bandwidth consumer for most websites, accounting for 50–70% of page weight. Image optimization at the CDN edge reduces bandwidth dramatically without requiring changes to your origin.
Format conversion. Automatic WebP/AVIF conversion reduces image bandwidth by 30–50%. For a site serving 50 TB/month of images, that is 15–25 TB of savings per month. Some CDN providers (Cloudflare, Fastly, imgix) include image optimization in their pricing; others charge per transformation.
Responsive resizing. Serving a 2000px wide image to a 375px mobile viewport wastes 80% of the bandwidth. CDN-based responsive resizing serves the correct dimensions for each device, reducing image bandwidth by an additional 30–50% for sites with significant mobile traffic.
Quality reduction. Dropping JPEG quality from 90 to 75 reduces file size by 30–40% with minimal visible difference. SSIM (Structural Similarity Index) analysis confirms that quality 70–80 is perceptually lossless for most photographs at web viewing sizes.
Combined impact example. A site serving 100 TB/month of images at $0.08/GB spends $8,000/month on image bandwidth alone. With format conversion (-35%), responsive resizing (-30% of remaining), and quality optimization (-25% of remaining): 100 TB becomes 34 TB, saving $5,280/month.
What Are Committed-Use Discounts and When Do They Make Sense?
Committed-use agreements (also called reserved capacity or annual contracts) trade volume commitments for per-unit price reductions. The discounts are substantial but carry risk.
Typical discount structures:
| Commitment Level | Typical Discount | Risk |
|---|---|---|
| Monthly pay-as-you-go | 0% (list price) | None |
| Annual commit ($5K/mo) | 15–25% | Low (reasonable for stable traffic) |
| Annual commit ($25K/mo) | 25–40% | Medium (traffic must justify spend) |
| Multi-year ($100K+/mo) | 40–60% | High (locked in, use-it-or-lose-it) |
When to commit. Sign a committed-use agreement when: your traffic is stable or growing (not seasonal with deep troughs), you have at least 6 months of historical traffic data to forecast accurately, and the committed spend is below 80% of your expected minimum monthly usage. The 80% rule protects against paying for unused capacity during slow months.
Negotiation tips. CDN sales teams have significant pricing flexibility. Start at 30% below their initial offer. Request bandwidth banking (unused capacity rolls over to future months). Ask for burst provisions (temporary overage at committed rates instead of on-demand rates). Get the contract reviewed by your legal team for auto-renewal traps and exit penalties.
How Does Multi-CDN Arbitrage Reduce Costs?
Multi-CDN strategies route different traffic types or regions to the most cost-effective provider. This is not just a cost play—it also improves reliability and performance—but the cost savings are a compelling reason to adopt it.
Content-based routing. Route bulk static content (images, videos, downloads) through the cheapest per-GB provider (Bunny CDN at $0.01/GB or Cloudflare at $0). Route dynamic content and APIs through the provider with the best origin connectivity (CloudFront if your origin is AWS, Azure CDN if Azure). Route security-sensitive traffic through the provider with the strongest WAF (Cloudflare or Akamai).
Geographic routing. CDN pricing varies dramatically by region. CloudFront charges $0.085/GB in North America but $0.170/GB in India and $0.120/GB in Asia Pacific. A regional CDN might offer better rates in specific markets. Use DNS-based or load-balancer-based routing to direct each region to the cheapest qualified provider.
Implementation. The traffic director (DNS-based like NS1 or Route 53, or a global load balancer) resolves to the appropriate CDN endpoint based on geography, content type (via separate hostnames: static.example.com, api.example.com), or real-time cost/performance data. Monitor the routing decisions using CDN log analysis to ensure cost optimization does not degrade performance.
How Do You Reduce Origin Egress Costs?
Origin egress—bandwidth from your origin server to the CDN—is often the hidden cost that CDN users overlook. Cloud providers charge $0.09–0.12/GB for outbound bandwidth, and every cache miss triggers an origin fetch.
Origin shield. An origin shield consolidates all cache fills through a single CDN PoP. Instead of 200 PoPs each independently fetching from origin, they fetch from the shield, which fetches once from origin. This can reduce origin egress by 90%+ for cacheable content. The shield adds 5–15 ms latency for cache misses but saves significantly on origin bandwidth costs.
Cache warming. Proactively populate the CDN cache by sending synthetic requests for your most popular content from each PoP. This prevents the burst of origin traffic that follows a cache purge or CDN configuration change. See Cache Warming Techniques for implementation approaches.
Conditional requests (If-Modified-Since/If-None-Match). When cached content expires, the CDN sends a conditional request to origin. If the content has not changed, origin responds with 304 Not Modified (a few hundred bytes) instead of the full resource. This reduces origin egress for revalidation by 95–99%.
What Free Tier Strategies Can You Use?
CDN free tiers are not just for hobbyists. Strategic use of free tiers can offset significant portions of your CDN bill, even for commercial sites.
Cloudflare Free. Unlimited bandwidth, SSL, basic WAF, and CDN caching. For sites where Cloudflare's feature set is sufficient, the free tier is genuinely production-ready. Limitations: no custom page rules (only 3 on free), limited WAF rules, and community-only support.
CloudFront free tier. 1 TB of data transfer and 10 million HTTP/HTTPS requests per month, perpetually free. Useful for development environments, staging sites, and low-traffic production sites.
Hybrid approach. Use Cloudflare Free for static content delivery and a paid provider (CloudFront, Fastly) for dynamic content and API acceleration. This leverages Cloudflare's unlimited bandwidth for the bulk of traffic while paying only for the dynamic content that needs a provider with specific features. This pairs well with API acceleration strategies.
How Do You Build a CDN Cost Dashboard?
Visibility drives optimization. Build a cost dashboard that tracks spending by category, identifies anomalies, and measures the impact of optimizations.
Key metrics to track:
- Total CDN spend (daily, weekly, monthly trend)
- Cost per GB delivered (watch for regional pricing changes)
- Cache hit ratio (the primary cost driver)
- Origin egress volume and cost
- Feature surcharges (edge functions, image optimization, WAF)
- Cost per 1000 page views (your unit economics metric)
Alerting thresholds. Set alerts for: daily spend exceeding 2x the 30-day average (traffic spike or DDoS), cache hit ratio dropping below 80% (configuration regression), and origin egress exceeding historical baseline by 50% (broken caching). These alerts catch cost problems within hours instead of at the monthly bill review.
Combine CDN cost data with the performance insights from Real User Monitoring to ensure that cost optimizations do not inadvertently degrade user experience. The goal is the lowest cost that meets your performance targets, not the lowest cost regardless of consequences.