Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

206 partial not caching

Tags:

http

partial

I'm having trouble figuring out what I need to set on my Partial Responses (206) in order for Google Chrome and Firefox to cache the byte data sent to the browser. Internet explorer seems happy with my headers, by from what I gather, Chrome is very specific about what constitutes a valid response for caching.

Background:

I'm loading a element for a long video, and I am seeking to clips within the same video. When I seek between clips, and come back to the first clip... instead of playing the cached data, it requests the data from the server again in another 206 request.

Here are the headers from one of these reuests:

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>

Any Ideas?

In internet Explorer, I can see that the request includes "If-Unmodified-Since" and "If-Match" values, which I am handling on the server. Chrome doesn't include these in the request header though? I assume because the original response didn't give it something it needed to cache the content in the first place.

IE Headers:

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
like image 249
YAreAllTheDisplayNamesTaken Avatar asked Nov 07 '13 09:11

YAreAllTheDisplayNamesTaken


1 Answers

I don't know the exact state of this in 2017 (question was from 2013), but at least today you might be able to pull this off using service workers. Service workers allow you to intercept requests and send back responses from within a js process without actually going to the server, based on your own caching logic.

So while this is not a direct solution to your problem, it might be a viable workaround now.

like image 123
Evert Avatar answered Oct 13 '22 19:10

Evert