Search code examples
javascriptamazon-web-servicesamazon-cloudfront

Cloudfront Brotli Compression Not Working


I have a javascript file hosted on Cloudfront, the 'Compress objects automatically' settings are set to Yes in the distribution settings. When I request this javascript file, I always get the gzipped version even though my browser accept-encoding is set to: accept-encoding: gzip, deflate, br.

How can I fix this to get Cloudfront to return the Brotli version whenever the browser supports it instead of always sending the gzipped version?


Solution

  • If the file is stored on S3 uncompressed, and Gzip compression is working, one setting to check is whether the Cache Policy that you have attached to this cache behavior has Brotli compression enabled. You have to enable Brotli and Gzip compression separately.