Introduction When CDN cache does not update after content changes, users see outdated content. This is especially problematic after deployments, content updates, or emergency fixes.

Symptoms - Updated files not visible through CDN after deployment - Purge request returns success but content still stale - Different CDN edge locations showing different content - Cache-Control headers being ignored - Origin shows new content but CDN shows old

Common Causes - Cache-Control max-age too long - CDN not respecting purge requests - Origin shield caching stale content - Purge not propagated to all edge locations - Versioned URLs not updated in application

Step-by-Step Fix 1. **Verify origin has correct content': ```bash curl -I http://origin.example.com/file.css # Check Last-Modified and ETag ```

  1. 1.**Purge CDN cache':
  2. 2.```bash
  3. 3.# CloudFront
  4. 4.aws cloudfront create-invalidation --distribution-id E123 --paths "/*"
  5. 5.# Fastly
  6. 6.curl -X PURGE https://api.fastly.com/service/<id>/purge_all
  7. 7.# Cloudflare
  8. 8.curl -X POST https://api.cloudflare.com/client/v4/zones/<id>/purge_cache \
  9. 9.-H "Authorization: Bearer <token>" \
  10. 10.-H "Content-Type: application/json" \
  11. 11.-d '{"purge_everything":true}'
  12. 12.`
  13. 13.**Check cache headers on origin':
  14. 14.```bash
  15. 15.curl -I https://cdn.example.com/file.css
  16. 16.# Look for: Cache-Control, Age, X-Cache
  17. 17.`

Prevention - Use versioned asset URLs (file.v2.css) - Set appropriate Cache-Control headers per content type - Implement CDN cache warming after deployments - Monitor CDN cache hit ratio - Test content updates through CDN after every deployment