206部分不缓存

时间:2013-11-07 09:27:28

标签: http partial

我无法弄清楚我需要在Partial Responses(206)上设置什么才能让Google Chrome和Firefox缓存发送到浏览器的字节数据。 Internet Explorer似乎对我的标题感到满意,根据我收集的内容,Chrome非常具体地说明了什么构成了有效的缓存响应。

背景:

我正在为一个长视频加载一个元素,我正在寻找同一视频中的剪辑。当我在剪辑之间寻找,并回到第一个剪辑...而不是播放缓存的数据时,它会在另一个206请求中再次从服务器请求数据。

以下是其中一个请求的标题:

Request URL:http://localhost:51202/Stream/StreamVideo?videoFileGuid=e824795d-18af-43cb-935d-b793dbbe36fb
Request Method:GET
Status Code:206 Partial Content

Request Headers
GET /Stream/StreamVideo?videoFileGuid=e824795d-18af-43cb-935d-b793dbbe36fb HTTP/1.1
Host: localhost:51202
Connection: keep-alive
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)     Chrome/30.0.1599.101 Safari/537.36
Accept: */*
Referer: http://localhost:52309/Playlists/Playlist/ViewPlaylist?playlistGuid=165deee2-e5d3-435c-ac19-f2f7357cf6d2
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Cookie: .ASPXAUTH=<snip>
Range: bytes=463809580-
Query String Parameters
videoFileGuid=e824795d-18af-43cb-935d-b793dbbe36fb

Response Headers
HTTP/1.1 206 Partial Content
Cache-Control: public
Content-Length: 421590265
Content-Type: video/mp4
Content-Range: bytes 463809580-885399845/885399846
Expires: Thu, 14 Nov 2013 08:54:30 GMT
Last-Modified: Fri, 01 Nov 2013 14:33:04 GMT
Accept-Ranges: bytes
ETag: 515e8d9b-87f4-4e49-ac64-17c33e091b4a
Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 4.0
Content-Disposition: inline; filename="StreamVideo"
X-AspNet-Version: 4.0.30319
X-SourceFiles: =<snip>
X-Powered-By: ASP.NET
Date: Thu, 07 Nov 2013 08:54:46 GMT
X-Powered-By:ASP.NET
X-SourceFiles:=<snip>

任何想法?

在Internet Explorer中,我可以看到该请求包含我在服务器上处理的“If-Unmodified-Since”和“If-Match”值。 Chrome虽然在请求标题中不包含这些内容?我假设是因为原始响应没有给出首先缓存内容所需的东西。

IE标题:

Key         Value
Request         GET /Stream/StreamVideo?videoFileGuid=e824795d-18af-43cb-935d-b793dbbe36fb HTTP/1.1
Accept          */*
If-Unmodified-Since Fri, 01 Nov 2013 14:33:04 GMT
If-Match        515e8d9b-87f4-4e49-ac64-17c33e091b4a
Range           bytes=884228096-885399845
User-Agent      Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Referer         <myURL>
GetContentFeatures.DLNA.ORG 1
Pragma          getIfoFileURI.dlna.org
Accept-Language     en-ZA
Accept-Encoding     gzip, deflate
Host            <myHost>
DNT         1
Connection      Keep-Alive

1 个答案:

答案 0 :(得分:0)

我不知道2017年的确切状态(问题是从2013年开始),但至少今天你可以使用服务工作者来解决这个问题。服务工作者允许您根据自己的缓存逻辑拦截请求并从js进程发回响应,而无需实际进入服务器。

因此,虽然这不是您问题的直接解决方案,但现在可能是一种可行的解决方法。