Alex
Alex

Reputation: 3791

html5 video caching on Explorer 9

I have some <video>s which are dynamically created & loaded using javascript document.createElement then I sample them using an offscreen canvas and mess with them.

All very fun and working great in every browser .... wait for it... except IE9 (surprise).

The problem is: when I clear the cache and reload IE it all works great, however when the videos are cached IE starts bitching about a:

DOM Exception: SECURITY_ERR (18) 

I've now read everything on the interweb about this and basically it's IE being stupid as this error is really about CORS and there's no way this is a CORS issue

So the question:

Is there a way I can use .htaccess to force IE9 (and only IE9) to prevent IE9 from caching the video or do I have to do that pony querysting thing on the video filenames?

Thanks very much indeed!

EDIT: the answer

In addition to FlavorScape's answer below, after a bit of experimention with the refs on his links this code seems to wor:

BrowserMatchNoCase "MSIE" isIE

<IfDefine isIE>
    ExpiresByType video/ogg                 "access plus 0 seconds"
    ExpiresByType audio/ogg                 "access plus 0 seconds"
    ExpiresByType video/mp4                 "access plus 0 seconds"
    ExpiresByType video/webm                "access plus 0 seconds"
</IfDefine>

Upvotes: 1

Views: 627

Answers (1)

FlavorScape
FlavorScape

Reputation: 14319

When I access things I don't want cached, I usually add a query string to the filename.

For Example:

someVideo.mp4?poop=Math.Round( Math.random()*10000)

you can set the no-cache on the server header. See reference

This is how to do it in .htaccess http://www.askapache.com/htaccess/apache-speed-cache-control.html

Cache-Control   = "Cache-Control" ":" 1#cache-directive
    cache-directive = cache-request-directive
         | cache-response-directive
    cache-request-directive =
           "no-cache"                          ; Section 14.9.1
         | "no-store"                          ; Section 14.9.2
         | "max-age" "=" delta-seconds         ; Section 14.9.3, 14.9.4
         | "max-stale" [ "=" delta-seconds ]   ; Section 14.9.3
         | "min-fresh" "=" delta-seconds       ; Section 14.9.3
         | "no-transform"                      ; Section 14.9.5
         | "only-if-cached"                    ; Section 14.9.4
         | cache-extension                     ; Section 14.9.6
     cache-response-directive =
           "public"                               ; Section 14.9.1
         | "private" [ "=" <"> 1#field-name <"> ] ; Section 14.9.1
         | "no-cache" [ "=" <"> 1#field-name <"> ]; Section 14.9.1
         | "no-store"                             ; Section 14.9.2
         | "no-transform"                         ; Section 14.9.5
         | "must-revalidate"                      ; Section 14.9.4
         | "proxy-revalidate"                     ; Section 14.9.4
         | "max-age" "=" delta-seconds            ; Section 14.9.3
         | "s-maxage" "=" delta-seconds           ; Section 14.9.3
         | cache-extension                        ; Section 14.9.6
    cache-extension = token [ "=" ( token | quoted-string ) ]

Or you could try setting the no-cache document header, but I think that only applies to the document itself.

Upvotes: 1

Related Questions