问题
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>
回答1:
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.
来源:https://stackoverflow.com/questions/37265349/force-browser-to-update-cached-html5-video-object