Cloudfront 如何避免每次 If-Modified-Since header 请求

Cloudfront how to avoid If-Modified-Since header request everytime

AWS Cloudfront 文档说:

If you set the TTL for a particular origin to 0, CloudFront will still cache the content from that origin. It will then make a GET request with an If-Modified-Since header, thereby giving the origin a chance to signal that CloudFront can continue to use the cached content if it hasn't changed at the origin

我需要配置我的动态内容。我已经将 TTL 设置为 0.. 我希望每个请求都始终转到 Origin。有没有办法用 If-Modified-Since header 来避免这个额外的 GET 请求!为什么每次都有这个额外的要求!

Is there a way I avoid this additional GET request

听起来好像您误解了您正在阅读的内容。不幸的是,您没有引用来源,因此很难返回并获取更多上下文;但是,这并不是指 "extra" 请求。

It will then make a GET request with an If-Modified-Since header

这是指每次浏览器随后请求该对象。 CloudFront 发送带有 If-Modified-Since:next 请求,以便您的源服务器具有 returning a [=13] 的 option =] 响应...它不会向源发送两个请求以响应来自浏览器的一个请求。

如果您的内容始终是动态的,return Cache-Control: private, no-cache, no-store 并将最小 TTL 设置为 0。

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html#ExpirationDownloadDist

这是我从 AWS 得到的答案:

However, if you forward all headers for that particular origin, the request will go to the origin every time without the If-Modified-Since header mentioned [1]. Please view the excerpt from the link below for further detail:

“Forward all headers to your origin Important If you configure CloudFront to forward all headers to your origin, CloudFront doesn't cache the objects associated with this cache behavior. Instead, it sends every request to the origin.”