title: IE not caching video (works in Chrome)
body: <p>On an HTML page constructed using php + jsquery + javascript (e.g. index.php), a video tag has a source that is another php page, with a GET field specifying which video to load (e.g. "getfile.php?file=111").</p>
  
  <p>Buttons switch which video is playing; e.g. javascript</p>
  
  <pre><code>var video = document.getElementById('flyover');
  var source = video.getElementsByTagName('source')[0];
  source.setAttribute('src', "getfile.php?file=222");
  </code></pre>
  
  <p>getfile.php emits HTTP headers, then <code>fpassthru</code> of file contents.</p>
  
  <pre><code>...
  header('Content-Type: video/mp4');
  header('Content-Disposition: attachment; filename='.basename($file-&gt;FileName));
  header('Content-Transfer-Encoding: binary');
  $seconds_to_keep = ...
  header ("Expires: " . gmdate("D, d M Y H:i:s", time() + $seconds_to_keep) . " GMT");
  header('Cache-Control: public, max-age=' . $seconds_to_keep);
  header('Content-Length: ' . filesize($filename));
  
  fpassthru($fp);
  exit;
  </code></pre>
  
  <p>Fiddler proxy used to confirm headers:</p>
  
  <pre><code>#   Result  Protocol    Host    URL Body    Caching Content-Type
  47  200 HTTP    ... /getfile.php?file=2639  10,113  public, max-age=31536000; Expires: Thu, 06 Aug 2015 20:20:30 GMT    video/mp4
  </code></pre>
  
  <p>Test actions:</p>
  
  <ol>
  <li>Load page</li>
  <li>Wait for video #1 to finish playing (And Fiddler updates Caching info from "-1" to "max-age / Expires" details)</li>
  <li>Push button for video #2</li>
  <li>Wait for video #2 to finish playing (And Fiddler updates Caching info)</li>
  <li>Push button for video #1</li>
  </ol>
  
  <p>On Chrome, the result is that video #1 immediately starts playing (and buffering bar shows halfway loaded, which is the most I ever see at video start). Fiddler does NOT show a new "getfile" request to server.</p>
  
  <p>On IE 11, there is a delay while video #1 buffers (and buffering bar shows zero loaded at video start). Fiddler DOES show a new "getfile" request to server.</p>
  
  <p>IE's cache setting is "automatic". (Temporary Internet Files / Check for newer versions of stored pages = "Automatically").  Cache size is 250 mb, videos are ~ 6 mb each, and cache was emptied prior to start of testing.</p>
  
  <p>Confirmed that URL is exactly the same (according to fiddler, and using alert pop-up in javascript).</p>
  
  <p>Q: What else could affect IE's failure to cache these videos?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>IMAGES, obtained via the same url, but with different query field fileid value, and different Content-Type header, ARE caching in IE:  If quit browser, and restart browser, and go the the same page, Fiddler does not show any "/getfile.php?fileid=333" requests for those images. (It did show those requests the first time page was loaded after cache clear.)</p>
  
  <p>The only change in php code executed (for images versus video) is a single if / else if statement, that controls what Content-Type header is emitted.</p>
  
  <p>Perhaps it is IE 11's caching policy to not cache videos?</p>
  
  <p>The logic does emit a Content-Length header with file size, and the client internet options cache (250 mbs) is much larger than the file size (6 mb), so it "should" be able to cache it.  Disk space free is many GBs.</p>
  
  <p><strong>UPDATE #2</strong></p>
  
  <ul>
  <li>Restarting IE, after using Security tab to turn "Enable Protected Mode" off or on, does not change the above results.</li>
  <li>Increasing disk space to the maximum (1024 MB) does not change the above results.</li>
  <li>Setting IE's policy to "Check for newer versions of stored pages: Never" doesn't seem to "stick":  when close Internet Options, then re-open it, the radio button has returned to "Automatically".</li>
  <li>...</li>
  <li>Repeating Chrome test after the IE tests confirms that caching is still working correctly within Chrome.</li>
  </ul>
  
  <p><strong>UPDATE #3</strong></p>
  
  <p>php code on server does NOT test for HTTP_IF_MODIFIED_SINCE; I'm not sending Last-Modified header. I was assuming maxage would be sufficient. It is possible that IE would be smarter about caching video files if Last-Modified was present. If you have any experience with video over slow server connections, and have succeeded using a specific set of headers, then an answer with the approach you used would be useful.</p>