Prompt
What's the most cost-effective way to serve static assets globally using a content delivery platform?
Latest observation
The most cost-effective way to serve static assets globally is usually:
1) Put the assets behind a CDN
Use a CDN (Content Delivery Network) in front of your storage/origin so files are cached at edge locations close to users. This reduces origin traffic and latency.
Common low-cost options:
- Cloudflare CDN + R2 (often very cost-effective because egress can be low or free depending on setup)
- AWS S3 + CloudFront
- Google Cloud Storage + Cloud CDN
- Azure Blob Storage + Azure CDN
- Bunny.net (often popular for straightforward, low-cost static delivery)
2) Serve from object storage, not an app server
Store assets in object storage (S3, R2, GCS, Blob Storage) rather than serving them from your web app. This is much cheaper and more scalable.
3) Make files highly cacheable
Set long cache headers for versioned assets:
Cache-Control: public, max-age=31536000, immutable
Then use versioned filenames like:
app.3f2c1a.jsstyles.a91bd.css
This maximizes edge caching and minimizes repeated origin fetches.
4) Use compression and modern formats
- Enable Brotli or gzip for text assets
- Use optimized image formats like WebP or AVIF
- Resize images to actual display sizes
This cuts bandwidth costs significantly.
5) Reduce origin requests
- Bundle/minify assets where appropriate
- Remove unused assets
- Use cache busting with hashed filenames
- Avoid frequent invalidations
6) Pick the right pricing model
For lowest cost, compare:
- Bandwidth/egress pricing
- Request pricing
- Storage pricing
- Free tier limits
- Cache invalidation costs
- Regional coverage
For many small-to-medium sites, Cloudflare + R2 or Bunny.net are often among the most cost-effective. For AWS-heavy stacks, S3 + CloudFront is convenient but can be pricier on egress.
Rule of thumb
If you want the cheapest global static delivery:
- Use object storage
- Put a CDN in front
- Use long-lived cache headers
- Use hashed filenames
- Compress assets
If you want, I can recommend the cheapest setup based on your traffic level, file sizes, and cloud provider.