HTML5 Video Force Reload / Prevent Cache
In the HTML5 Video tag, how can I force streaming the HTML5 video chunks on demand/load and prevent them from getting cached on the client side? In simpler words, how can I prevent the browser from caching the HTML5 video?
My ultimate goal is to make the video's source available for a short period of time (say 10 minutes) and then I will invalidate/expire the source. I know how to invalidate a video HTTP URL in ASP.NET or whether to do so if the video is hosted on Amazon S3 storage. However, if the browser caches my video, it will be on its own and the video would not be requested from the server anymore.
I've already checked out this detailed article about working with HTML5 videos with no much luck.
I see two decent options, and by using both you should have reasonable results:
Use unique urls by appending a timestamp:
domain.com/video.mp4?t=" + new Date();
Or something to this effect. You can then check the value of t and reject if it's outside your window. By always requesting a new url because of the Date(), the browser will be forced to ask the server for the file.
Cache-control headers. Make sure you're setting them for for your video files in htaccess to force a 10 minute refresh life span:
Header set Cache-Control "max-age=600" AddType video/webm .webm
60s x 10m = 600
Edit: Just saw the asp.net tag, set the cache control header in IIS.
链接地址: http://www.djcxy.com/p/64356.html下一篇: HTML5视频强制重新加载/防止缓存