0

I ran into an issue where regardless of the preload attribute setting, when IE9 makes a request for a video, and the video is served by x-sendfile, the request is listed as pending and keeps the connection open.

Consequently, if you have 10 videos trying to load, IE9 will quickly eat up all of its available connections and the browser will not be able to make further requests.

When telling IE9 to request the same video from Apache, without X-Sendfile, Apache serves a small portion of the file as a 200 request. Then the browser makes a request later when the play button is pressed to serve a range of the file.

It looks like X-Sendfile is causing Apache to serve the entire file initially, instead of serving just a part of it.

How can I make X-Sendfile requests via Apache function the same as a regular request to Apache?

Kevin Somers-Higgins
  • 957
  • 1
  • 10
  • 12

1 Answers1

0

Setting the "Accept-Ranges" header like header("Accept-Ranges: bytes"); tells IE9 to attempt to stream the file by default, instead of serve it in one chunk.

It's recommended to check that the HTTP request is version 1.1 though before setting, since 1.0 doesn't support the header.

if (isset($_SERVER['SERVER_PROTOCOL']) && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1') {
    header("Accept-Ranges: bytes");
}

I wasn't able to find any documentation on this anywhere, so I'm posting my solution here.

Kevin Somers-Higgins
  • 957
  • 1
  • 10
  • 12
  • 1
    setting the Accept-Ranges header doesn't cause X-Sendfile to do anything at all. It tells the client that you support `Range: bytes` requests. – hobbs Dec 10 '14 at 23:05
  • @hobbs Nice catch! It looks like I had come to the right solution with the wrong conclusion! I'll amend my answer. – Kevin Somers-Higgins Dec 10 '14 at 23:15