Back to articles
Why is my CDN slow? Bypassing the 10MB Compression Limit on AWS CloudFront
How-ToDevOps

Why is my CDN slow? Bypassing the 10MB Compression Limit on AWS CloudFront

via Dev.tofelipecarrillo100

The "Silent" Performance Killer You’ve deployed your data-heavy app to AWS CloudFront. You checked the "Compress Objects Automatically" box. You assume your 12MB GeoJSON or a 15MB JavaScript module is being zipped down to a manageable size. It isn't. AWS CloudFront has a strict, hard-coded 10MB limit for automatic compression. If your file is 10.1MB, CloudFront serves the full-fat, uncompressed version. While you're testing on high-speed office Wi-Fi, your users on 4G/LTE suffer waiting 20 seconds or more for the app to load, and your Lighthouse scores are in the basement. To fix this, you have to take matters into your own hands: Pre-compress your assets and use Lambda@Edge to serve them. 🛠️ Step 1: Pre-Compressing the "Monsters" Since CloudFront won't touch files over 10MB, we compress them ourselves. We can do this manually but it is much more optimal if we do the work at build time. Using Vite, we can generate high-efficiency compression (Gzip and Brotli) for only the files that ex

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles