- Newest
- Most votes
- Most comments
We’re sorry, but we’re having difficulty fully understanding your issue. Could you please provide a more brief overview or clarify the specific points you’re concerned about?
thanks Pritam
- Response from S3 must include Content-Length
- Not all files can be compressed by cloudfront
- The response must not include a Content-Encoding header!
- Size of files should be at least 1KB So first you have to ensure Cloudfront compressing at all. Check all the requirements above:
- Test simply with CURL some of your static files in Static files in Cloudfront distribution
curl -H "Accept-Encoding: gzip" https://test.com/static.js" - Check if Content-Encoding: gzip response header present
If its present then you can start solving the problem, file size from EC2 is much smaller. EC2 probably using NGINX or Apache to deliver static files, which migh have different settings for compression
Hi Oleksandr, I tested the compression of our static files served by CloudFront using the following command : curl -H "Accept-Encoding: gzip" https://<cloudFrontLink>/main.xyz.esm.js -I
Here is the response I received (sensitive information is in xyz): HTTP/2 200 content-type: application/javascript content-length: 10555700 date: Thu, 19 Sep 2024 05:49:27 GMT last-modified: Wed, 18 Sep 2024 13:06:51 GMT etag: "55b3f0a7533ecbaae29ec8ff5ed7d6b0-2" server: AmazonS3 x-cache: Hit from cloudfront via: 1.1 xyz.cloudfront.net (CloudFront) x-amz-cf-pop: xyz x-amz-cf-id: xyz age: 3
Based on the response, the following points are satisfied: 1.The response from S3 includes the Content-Length header. 2.Not all files can be compressed by CloudFront. 3.The response does not include a Content-Encoding header. 4.The size of the file is at least 1KB. However, the Content-Encoding: gzip header is not present in the response, indicating that CloudFront is not serving the file in a compressed format.
Please let me know how we should proceed to ensure that CloudFront compresses and serves the files correctly.
Relevant content
- asked 2 years ago
- asked 2 years ago

To summarize it , I am facing issue regarding build compression on cloudFront.