强制浏览器更新缓存的HTML5视频对象 [英] Force browser to update cached HTML5 video object

查看:350
本文介绍了强制浏览器更新缓存的HTML5视频对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法强制网页浏览器,即Firefox或Firefox移动(最新版本)更新HTML5视频对象,当页面重新加载?



我是使用CTRL + R,重新加载按钮和2分钟的HTTP刷新,但是除非重新启动浏览器或清除缓存,否则这些选项都不会更新视频文件。此外,Firebug甚至不会显示正在加载的MP4文件。



注意:MP4文件是每2分钟由一个shell脚本生成的。我已经通过检查时间戳验证了视频正在更新,加上它工作,如果我退出/重新启动Firefox。



这是我的代码:

 <!DOCTYPE html> 

< html>

< head>
< title>相机< / title>
< meta http-equiv ='refresh'content ='120'>
< / head>

< body>
< h3>相机< / h3>
< video id =CamLoopheight =100%width =100%autoplay loop>< source src ='/ Get / Cams / _Loop.mp4'>< / source><< ; /视频>
< / body>

< / html>


解决方案

是的。附加一个随机参数的URL,通常是一个时间戳。从本质上讲,参数没有任何作用,但是这使得浏览器认为url是不同的,并且会强制自己加载资源

  http://yoursite.com/path/to/resource.mp4?t=1923801924 

对于您的方法,但是,您需要JS来设置视频的源代码,而不是每次重新加载时都要使用相同的值。


Is there a way to force a web browser, i.e. Firefox or Firefox Mobile (latest versions) to update a HTML5 video object when the page reloads?

I am using CTRL+R, reload button, and a HTTP refresh of 2 minutes, but none of these options "update" the video file unless restart the browser or clear cache. Additionally, Firebug does not even show the MP4 file being loaded in.

Side note: The MP4 file is generated by a shell script every 2 minutes. I have verified that the video is updating by checking the timestamp, plus it works if I exit/restart Firefox.

Here is my code:

<!DOCTYPE html>

<html>

<head>
<title>Cameras</title>
<meta http-equiv='refresh' content='120'>
</head>

<body>
<h3>Cameras</h3>
<video id="CamLoop" height="100%" width="100%" autoplay loop><source src='/Get/Cams/_Loop.mp4'></source></video>
</body>

</html>

解决方案

Yes. Append a random param to the url, usually a timestamp. Essentially, the param does nothing, but this makes the browser think the url is different, and will force itself to load the resource

http://yoursite.com/path/to/resource.mp4?t=1923801924

For your approach, however, you'll need JS to set the video's source instead of relying on the same exact value on every reload.

这篇关于强制浏览器更新缓存的HTML5视频对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆