0

I have an Amazon CloudFront that initially was not compressing objects. I switched "Compress objects automatically" to "Yes" and invalidated the cache using /*. But still, the objects were not getting compressed. I followed https://stackoverflow.com/a/65423792/7760998 and updated my CORS policy on the S3 bucket and again invalidated the cache but no luck.

Below is the cURL response headers with the Accept-Encoding: gzip header

$ curl -sD - -o /dev/null -H 'Accept-Encoding: gzip' URL.js
HTTP/2 200 
content-type: text/javascript
content-length: 2469622
vary: Accept-Encoding
date: Thu, 22 Dec 2022 08:42:57 GMT
cache-control: max-age=0
last-modified: Thu, 22 Dec 2022 07:00:40 GMT
etag: "6b5ba54f857aae09f214d3b6bb988cbc"
server: AmazonS3
x-cache: Miss from cloudfront
via: 1.1 3964202601822e49b477697ad1a0d7e8.cloudfront.net (CloudFront)
x-amz-cf-pop: DEL54-C1
x-amz-cf-id: 1PaR9jhxIgoP3nq8Ut5YDqrV7sQmK98KJRdjMyo3ff9UOTVATTxzKg==

Below is the one without

$ curl -sD - -o /dev/null URL.js
HTTP/2 200 
content-type: text/javascript
content-length: 2469622
vary: Accept-Encoding
date: Thu, 22 Dec 2022 08:44:30 GMT
cache-control: max-age=0
last-modified: Thu, 22 Dec 2022 07:00:40 GMT
etag: "6b5ba54f857aae09f214d3b6bb988cbc"
server: AmazonS3
x-cache: Miss from cloudfront
via: 1.1 13cacaf041f81d18c39777fbcdf7705c.cloudfront.net (CloudFront)
x-amz-cf-pop: DEL54-C1
x-amz-cf-id: cGqw2Fk7WAnNYn2HcbfkosZMHgAYE-gIZLtkviSjVhkthQI3oxr0ZQ==

How can I enable GZIP compression on my JS files?

Solved edit: Thanks to the comment from @Ankush Jain, I was able to resolve the issue. This answer solved it.

Samkit Jain
  • 1,560
  • 2
  • 16
  • 33
  • Your requests are getting served from S3 instead of CloudFront as we can see the following response headers: - `server: AmazonS3` - `x-cache: Miss from cloudfront` – Ankush Jain Dec 22 '22 at 11:42

0 Answers0