云端压缩似乎不起作用

cloundfront compress doesn't seem to work

我已将云端配置为 Compress Objects Automatically。源服务器是 s3 bucket。我通过 cloudfront 将文件上传到 s3,然后向该文件发送 GET 请求。但是 return content-type 不是 gzip。下面是我发送的请求,你可以看到响应内容类型是application/octet-stream。我在 header 中添加了 Accept-Encoding: gzip 但为什么不能 return 压缩内容?

$ 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==

确保对象满足 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.

查看 types of files that CloudFront can compress 的列表。

在这种情况下,问题似乎是 CloudFront 无法压缩 application/octet-stream