如何强制Cloudfront仅每5秒而不是24小时缓存一次动态内容

时间:2019-05-09 14:56:00

标签: amazon-cloudfront

My desired behavior is to have cloudfront cache my origin(api endpoint that returns json).

无论我在原始位置的max-age标头中放置了什么值,还是在Cloudfront分布中输入了什么“ ttl”值,当使用curl与a时,都会在cloudfront中命中分布点缓存24小时php后端。通过Chrome浏览器访问端点时,它会按需要每5秒缓存一次(我认为chrome在请求标头中发送了no-cache)

是否有人建议如何强制Cloudfront每隔5秒在我的网站上缓存新数据,尤其是在使用curl时?

我实际上达到了一个剩余的api点,该点正在向回发送json,需要每五秒钟将json动态地缓存在cloudfront中。需要在5秒钟后刷新缓存,以便即使数据相同也可以提供新数据。原点是动态内容,每小时都会每小时变化一次,并且不是静态的。

是否不可能超过24小时缓存限制?

我尝试了不同的Cache-Control标头,例如max-age和s-maxage 我曾尝试在我的云端事务中更改ttl时间

我已将“对象缓存”设置为“自定义”,并且:

Min TTL is 0
Max TTL is 5
Default TTL is 5

我的来源标头是:

HTTP/1.1 200 OK
Date: Thu, 09 May 2019 14:15:17 GMT
Server: Apache/2.4.39 (cPanel) OpenSSL/1.0.2r mod_bwlimited/1.4 mpm-itk/2.4.7-04
Last-Modified: Thu, 09 May 2019 14:12:57 GMT
ETag: "e1ab8bae1d38bfceecece2c36df378c1-gzip"
X-Robots-Tag: noindex, follow
Link: <https://www.example.com/json/>; rel="https://api.w.org/"
Cache-Control: max-age=5
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 789
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json

0 个答案:

没有答案