Reputation: 42490
I have configured cloudfront to Compress Objects Automatically
. The origin server is s3 bucket. I uploaded a file to s3 through cloudfront then send a GET request to the file. But the return content-type is not gzip. Below is the request I sent and you can see the response content type is application/octet-stream
. I have added Accept-Encoding: gzip
in the header but why can't it return a compressed content?
$ curl -I -H "Accept-Encoding: gzip" https://dnruqi0psnxg6.cloudfront.net/images/cells/dc0c2f15-065b-4f3c-a4d6-81c3b09a163f.png
HTTP/2 200
content-type: application/octet-stream
content-length: 142317
date: Fri, 15 Mar 2019 22:58:49 GMT
last-modified: Fri, 15 Mar 2019 22:58:49 GMT
etag: "c6d54353c861d0145e10b1abdcb2976c"
x-amz-version-id: jgFwqD.F6lzvjbgcjfO.E6KK3IdHttaR
accept-ranges: bytes
server: AmazonS3
age: 29
x-cache: Hit from cloudfront
via: 1.1 0ea9662a9e73b2ca5836ede6924f81b0.cloudfront.net (CloudFront)
x-amz-cf-id: MTgwzb8KZinic50msfORINK2pSHW8QCOv82ur0Lq3-jH3WH_8prvow==
Upvotes: 0
Views: 462
Reputation: 9814
Make sure that the objects meet the following criteria from the docs:
The file must be of a type that CloudFront compresses.
The file size must be between 1,000 and 10,000,000 bytes.
The response must include a Content-Length header so CloudFront can determine whether the size of the file is in the range that CloudFront compresses. If the Content-Length header is missing, CloudFront won't compress the file.
The response must not include a Content-Encoding header.
See the list of types of files that CloudFront can compress.
In this case the problem appears to be that application/octet-stream
is not compressible by CloudFront.
Upvotes: 1