为 CloudFront 禁用缓存

Disabling Cache for CloudFront

我正在使用自己的域通过 CloudFront 为 HTTPS s3 存储桶提供服务。我不希望它缓存,因为它用于 QA 环境。

我想知道我怎样才能做到这一点。是使用 Origin Cache Headers 还是使用 0 Time To Live 自定义?

请在 AWS 管理控制台 (CloudFront) 中使用 自定义选项(行为 -> 缓存行为设置) 并相应地输入最小 TTL、默认 TTL 和最大 TTL 的值。

Minimum TTL

Specify the minimum amount of time, in seconds, that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The default value for Minimum TTL is 0 seconds.

Maximum TTL

Specify the maximum amount of time, in seconds, that you want objects to stay in CloudFront caches before CloudFront queries your origin to see whether the object has been updated. The value that you specify for Maximum TTL applies only when your origin adds HTTP headers such as Cache-Control max-age, Cache-Control s-maxage, or Expires to objects.

Default TTL

Specify the default amount of time, in seconds, that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify for Default TTL applies only when your origin does not add HTTP headers such as Cache-Control max-age, Cache-Control s-maxage, or Expires to objects.

现在,您只需在云端行为上设置 cachingDisabled 策略即可。

在 AWS 云端控制台上:

  • 转到您的分发 -> 行为选项卡
  • 编辑行为
  • 缓存键和原始请求下header -> Select 缓存禁用策略