场景:
我从自定义源(我的服务器)设置了一个Cloudfront分发,以逐步流式传输一系列mp4视频文件。
这些文件通过Chrome本地的HTML5视频api循环播放。每当视频结束时,Chrome会发出另一个对文件的请求。
当从我的服务器播放文件时,Chrome返回
Status Code:206 Partial Content (from cache)
在每个请求中,当从CloudFront播放同一文件时,Chrome永不缓存该文件并在每个请求中继续下载! 这是Chrome浏览器中来自Amazon CloudFront的响应头:
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中的响应头:
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
我有所遗漏吗?
也许原因在于CloudFront响应中缺少Keep-Alive
头部?或者是不同的HTTP协议版本(1.0 vs 1.1)?