cloudFront compression fields

0
  1. what should be the value of the 'Compress objects automatically' field in the Behavior-Level Compression Settings if I want the compression to be affected just by the Cache Policy-Level Compression Settings (according to the field - 'Compression support' (gzip/brotli) in the cache policy level)?
  2. what will happen if the 'Compress objects automatically' field in the Behavior-Level Compression Settings is enabeled, but both the 'gzip' and 'brotli' will be disabled in the Cache Policy-Level Compression Settings?
asked 5 months ago166 views
1 Answer
0

Hello!



Thank you for reaching out.

Before I proceed and answer your query, I would like to inform you that to configure CloudFront to compress objects you need update the cache behavior that you want to serve the compressed objects by doing all of the following:

  1. Make sure the Compress objects automatically setting is Yes. (In AWS CloudFormation or the CloudFront API, set Compress to true.)
  2. Use a cache policy to specify caching settings, and make sure the Gzip and Brotli settings are both enabled. (In AWS CloudFormation or the CloudFront API, set EnableAcceptEncodingGzip and EnableAcceptEncodingBrotli to true.)
  3. Make sure the TTL values in the cache policy are set to a value greater than zero. When you set the TTL values to zero, caching is disabled and CloudFront doesn’t compress objects.

Hence, you will need to make sure that you follow all the above requirements for compression to take place.

[+] Configuring CloudFront to compress objects: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html

I also found a repost documentation: https://repost.aws/knowledge-center/cloudfront-troubleshoot-compressed-files

Now, answering your queries:

  1. You should make sure that the 'Compress objects automatically' setting is Yes. After that you can have a cache policy where you can define which type of compression you want as per your use case (gzip/brotli).

i.e. You can have multiple behaviours along with different cache policies, you can define which type of compression you want to use. You can use either gzip/brotli or both.

  1. As explained above, if 'Compress objects automatically' is set to “YES” but both the 'gzip' and 'brotli' are disabled in the Cache Policy-Level Compression Settings then the compression will not take place.

Along with this, I would recommend you to refer the documentation:

[+] Notes about CloudFront compression: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-notes

Some other resources: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html

AWS
SUPPORT ENGINEER
Dhruv_R
answered 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions