【问题标题】:html5 video caching on Explorer 9Explorer 9 上的 html5 视频缓存
【发布时间】:2012-08-22 10:58:36
【问题描述】:

我有一些 <video>s 是使用 javascript document.createElement 动态创建和加载的,然后我使用屏幕外画布对它们进行采样并弄乱它们。

所有浏览器都非常有趣且运行良好....等待它...除了 IE9(惊喜)。

问题是:当我清除缓存并重新加载 IE 时,一切正常,但是当缓存视频时,IE 开始抱怨:

DOM Exception: SECURITY_ERR (18) 

我现在已经阅读了互联网上有关此的所有内容,基本上它是 IE 很愚蠢,因为这个错误实际上是关于 CORS 的,这不可能是一个 CORS 问题

那么问题来了:

有没有办法可以使用 .htaccess 来强制 IE9(并且只有 IE9)来阻止 IE9 缓存视频,或者我是否必须对视频文件名进行小马查询?

真的非常感谢!

编辑:答案

除了下面 FlavorScape 的回答之外,在对他的链接上的 refs 进行了一些试验之后,这段代码似乎可以工作:

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>

【问题讨论】:

    标签: javascript html internet-explorer .htaccess html5-video


    【解决方案1】:

    当我访问不想缓存的东西时,我通常会在文件名中添加一个查询字符串。

    例如:

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

    您可以在服务器标头上设置 no-cache。见reference

    这是在 .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 ) ]
    

    或者您可以尝试设置无缓存文档标题,但我认为这只适用于文档本身。

    【讨论】:

    • 是的,我也做查询字符串。但是这次它是一个 cms 驱动的 mvs javascript 应用程序,我宁愿找到一个 apache 指令说“不要缓存这些文件类型”
    • 这些是缓存控制的标题选项。
    • 查看我的更新,放入 apache 说明的链接以设置标题。查询字符串方法不行吗?
    • 是的,因为它都是 cms 驱动的,所以我不想在渲染视图时弄乱原始内容。我确实使用随机或基于时间的查询字符串,但通常用于此
    • 我不明白 CMS 与“原始内容”有什么关系。诶?或者“原始内容”在这种情况下甚至意味着什么。
    猜你喜欢
    • 1970-01-01
    • 2011-10-28
    • 2016-04-12
    • 1970-01-01
    • 2012-06-27
    • 2012-11-12
    • 1970-01-01
    • 2015-04-20
    • 2016-09-15
    相关资源
    最近更新 更多