Introduction When CDN compression is not working, static assets are served uncompressed, increasing bandwidth costs and page load times significantly.

Symptoms - Large CSS/JS file sizes in browser DevTools - Content-Encoding header missing from CDN response - Origin serves compressed but CDN serves uncompressed - Brotli not working, only gzip (or neither) - Compression working for some content types but not others

Common Causes - CDN compression not enabled in configuration - Content-Type not in CDN compression whitelist - Origin already compressing and CDN not re-compressing - Accept-Encoding header not forwarded to origin - Compressed version cached with wrong Content-Encoding

Step-by-Step Fix 1. **Check compression headers': ```bash curl -sI -H "Accept-Encoding: br, gzip" https://cdn.example.com/app.js \ | grep -i "content-encoding|vary" ```

  1. 1.**Enable CDN compression':
  2. 2.```bash
  3. 3.# CloudFront
  4. 4.aws cloudfront update-distribution --id E123 --cli-input-json '{
  5. 5."DistributionConfig": {
  6. 6."DefaultCacheBehavior": {"Compress": true}
  7. 7.}
  8. 8.}'
  9. 9.`
  10. 10.**Ensure Vary: Accept-Encoding header':
  11. 11.Origin must return Vary: Accept-Encoding header.

Prevention - Enable both Brotli and gzip compression on CDN - Verify compression for all text-based content types - Monitor compression ratio and bandwidth savings - Test compression after CDN configuration changes - Use CDN that supports automatic compression