apache - 浏览器 (Chrome) 不缓存来自 CloudFront 的 Assets

标签 apache google-chrome amazon-cloudfront

关闭。这个问题是off-topic .它目前不接受答案。












想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。

9年前关闭。




Improve this question




设想:
我设置了从自定义源(我的服务器)到渐进式流式传输 mp4 视频文件列表的 Cloudfront 分发。
这些文件通过 Chrome 原生 HTML5 视频 API 循环播放。每次视频结束时,Chrome 都会再次请求该文件。
从我的服务器播放文件时,Chrome 会返回

Status Code:206 Partial Content (from cache)
在每个请求上,从 CloudFront 播放相同文件时, Chrome 从不缓存文件并在每次请求时继续下载!
这些是来自 Chrome 中 Amazon CloudFront 的响应 header :
HTTP/1.0 206 Partial Content
Date: Mon, 19 Mar 2012 19:47:44 GMT
Server: Apache
Last-Modified: Mon, 19 Mar 2012 12:35:37 GMT
ETag: "a78e87ba-335d8e-4bb97cb9f887f"
Accept-Ranges: bytes
Content-Type: video/mp4
Content-Range: bytes 4228-3366285/3366286
Content-Length: 3362058
Age: 3819
X-Cache: Hit from cloudfront
X-Amz-Cf-Id: xxxxxx
Via: 1.0 xxxxxx.cloudfront.net (CloudFront)
Connection: keep-alive 
来自我的服务器(来源)的同一文件的 Chrome 中的响应 header :
HTTP/1.1 206 Partial Content
Date: Mon, 19 Mar 2012 20:50:40 GMT
Server: Apache
Last-Modified: Mon, 19 Mar 2012 12:35:37 GMT
ETag: "a78e87ba-335d8e-4bb97cb9f887f"
Accept-Ranges: bytes
Content-Length: 3366286
Content-Range: bytes 0-3366285/3366286
Keep-Alive: timeout=2, max=256
Connection: Keep-Alive
Content-Type: video/mp4
我错过了什么吗?
可能原因是缺少Keep-Alive CloudFront 响应的 header ?或者可能在不同的 HTTP 协议(protocol)版本(1.0 与 1.1)中?

最佳答案

从您的 CloudFront 响应中:

HTTP/1.0 206 Partial Content



HTTP/1.0 不包含 206 响应代码(在 HTTP/1.1 中添加),因此 chrome 的缓存层拒绝重用响应。 http://crbug.com/128116 中的更多特定于 chrome 的详细信息但简短的回答是 CloudFront 应该将 206 响应作为 HTTP/1.1,而不是/1.0。

关于apache - 浏览器 (Chrome) 不缓存来自 CloudFront 的 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9778369/

相关文章:

java - Apache CXF 2.x 选项未出现在 Eclipse Indigo 中的 Web 服务下

google-chrome - 如何在 chrome 版本 84 及更高版本中禁用帧速率限制?

macos - 在Mac上为Chrome安装VLC Web插件

amazon-web-services - 将 CloudFront 与外部托管的 DNS 结合使用,指向 EC2 实例

ssl - 调用 UploadServerCertificate 操作时出现客户端错误(MalformedCertificate) : Private key was in an unrecognized format

web - 如何为 Web 和 Amazon CloudFront 手动 gzip 文件

wcf - 从Apache服务器内托管WCF服务?

xml - ActiveMQ 5.11.1 不断抛出EOFException 不发送消息

javascript - 捕捉扩展中的全屏YouTube视频

php 文件自动重命名为 php.suspected