最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Force browser to update cached HTML5 video object - Stack Overflow

programmeradmin3浏览0评论

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>

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>
Share Improve this question asked May 17, 2016 at 0:42 user3260912user3260912 6412 gold badges7 silver badges19 bronze badges 1
  • have you tried adding a random cache-buster parameter (or just the timestamp) – Offbeatmammal Commented May 17, 2016 at 1:17
Add a ment  | 

1 Answer 1

Reset to default 9

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./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.

发布评论

评论列表(0)

  1. 暂无评论