如何配置 Cloudfront 以根据请求协议变化

How to configure Cloudfront to vary on request protocol

我的自定义来源 returns 响应可能因请求的协议而异。该站点需要一些 url 才能通过 http 访问,因此我不能只在 Cloudfront 中禁用 http。

但是,Cloudfront 正在缓存 http 响应并为通过 https 发出的请求提供服务。

我对这种行为感到困惑,因为 http://example.com is a different resource than https://example.com - 因此不应为它们提供相同的缓存响应。然而,Cloudfront 似乎是这样做的。

有没有办法指示 Cloudfront 在其缓存键中使用请求协议?

不,缓存键当前不支持请求协议。 https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-the-cache-key.html#cache-key-understand-cache-policy