amazon-web-services - 为什么 CloudFront 无法在压缩前保存 ETag?

标签 amazon-web-services amazon-cloudfront cdn

CloudFront documentation状态:

If you configure CloudFront to compress content, CloudFront removes the ETag response header from the files that it compresses. When the ETag header is present, CloudFront and your origin can use it to determine whether the version of a file in a CloudFront edge cache is identical to the version on the origin server. However, after compression the two versions are no longer identical. As a result, when a compressed file expires and CloudFront forwards another request to your origin, your origin always returns the file to CloudFront instead of an HTTP status code 304 (Not Modified).

为什么 CloudFront 不在压缩前保存文件的 ETag 并将其用于原始请求,以允许 304 代码?

最佳答案

文档的相应部分已更新。

如果您的来源确实包含强 ETag(例如 S3 包含)并且 CloudFront 会压缩内容(如果它被配置为这样做,例如对于文本或 json),它会根据要求规范(参见第 13.3.3 节。rfc2616-sec13)削弱了 ETag(例如,"foobar" 变为 W/"foobar")并且将其传递给观众。

可以存储它并稍后将其用于条件请求(If-None-Match: W/"foobar")。

ETag header

When the uncompressed object from the origin includes a valid, strong ETag HTTP header, CloudFront converts the strong ETag header value to a weak ETag, and returns the weak ETag value to the viewer. Viewers can store the weak ETag value and use it to send conditional requests with the If-None-Match HTTP header. This allows viewers, CloudFront, and the origin to treat the compressed and uncompressed versions of an object as semantically equivalent, which reduces unnecessary data transfer.

关于amazon-web-services - 为什么 CloudFront 无法在压缩前保存 ETag?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52373947/

相关文章:

amazon-web-services - 如何将 Amazon S3 对象移动到分区目录中

amazon-web-services - 是否可以在 AWS 上部署 Nuxt SSR 应用程序?

amazon-web-services - CloudFormation 部署不关联第二个 CloudFront 函数

cdn - 使用内容分发网络 (CDN) 的优点和缺点是什么?

Javascript - 窗口打开,使用 CDN

amazon-web-services - Cloudfront 分发批量失效的 JSON 是什么样的?

java - 将 AWS 签名 header 添加到所有放心请求中

amazon-cloudfront - 基于所选请求 header 的缓存 - Cloudformation 的 CloudFront 行为?

xml - 为什么在 S3/Cloudfront 上刷新我的 Angular 6 项目会导致错误?