问题描述
当出现以下情况时,CloudFront不会驱逐我的对象:
CloudFront is not evicting my objects when it is supposed to:
(这是这一个中的反向问题,其中CloudFront正在逐出对象尽早获得授权.)
(This is the reverse problems from this one, where CloudFront is evicting objects early, as it is entitled to do.)
这是一个典型的会话:
% curl -v -o /dev/null https://mycfdomain.me/file.json
< HTTP/2 200
< content-type: application/json
< content-length: 64
< date: Fri, 04 Dec 2020 13:17:32 GMT
< last-modified: Fri, 04 Dec 2020 04:08:04 GMT
< etag: "782c85948b6f309eaa1a483e5a535ecf"
< cache-control: public; max-age=60
< x-amz-version-id: XE56pcaQJCG.M_UGK2T_.eWgDMtOggZt
< accept-ranges: bytes
< server: AmazonS3
< x-cache: Hit from cloudfront
< via: 1.1 c1caaceb6655a57ae014aef7bc8ec389.cloudfront.net (CloudFront)
< x-amz-cf-pop: SFO20-C1
< x-amz-cf-id: C2YhfjBOOMpwpkxEg49vlP14vk4ijEsYNgXwkJdcIoK4YjsaqkCLxg==
< age: 327
<
它正坦率地承认它的物体已经超龄(327秒),声称它是从云顶撞上来的",应该是不应该的.
It’s returning on object it candidly admits is over-age (327 seconds), claiming it is a "hit from cloudfront", which it should not be.
这是等效的会话,直接进入S3.
Here is the equivalent session, going directly to S3.
c % curl -v https://mys3domain.s3.amazonaws.com/file.json
< HTTP/1.1 200 OK
< x-amz-id-2: I7mSgXtStAW7cgMqzxFvYwG78lH+BjjXp1pwuzdSYFwaK0w9s6v6IKGJVbuHY9DP6xkmvIvDnbg=
< x-amz-request-id: 6D366A4F89FBD06D
< Date: Fri, 04 Dec 2020 13:25:46 GMT
< Last-Modified: Fri, 04 Dec 2020 13:21:23 GMT
< ETag: "587bcf7b0f22d8b128b0f826e93bf18b"
< Cache-Control: public; max-age=10
< x-amz-version-id: iaHtXqm0jurqDyq2kyNDM1yShpyMaM7c
< Accept-Ranges: bytes
< Content-Type: application/json
< Content-Length: 117
< Server: AmazonS3
<
我检查了所使用的CF缓存策略的最小TTL:将其设置为1秒(这没关系,因为已设置 Cache-Control
.)
I checked the minimum TTL on the CF cache-policy I was using: it was set to 1 second (and it shouldn’t matter, since Cache-Control
is set.)
推荐答案
错误在这里:
< Cache-Control: public; max-age=10
应该是逗号,而不是分号,例如:
It should be a comma, not a semi-colon, like this:
< Cache-Control: public, max-age=10
这篇关于CloudFront忽略了S3中的Cache-Control标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!