How to avoid using old browser cache

After the video tag placed in the test site, the url unchanged if found, even if the replacement video file, the browser will still use the cached past video, other static documents should so be it.

Disable caching head inside does not solve the problem. Tested After src adding random numbers can make the browser load the new static files from the server.
Thus the following example, the use of which is at the rear end php
<video width="720" height=“540" controls> 
<source src="movie.mp4?<?php echo rand();?>" type="video/mp4"> </video> 

 

Can also be used at the front end javascript
<video width="720" height=“540" controls> 
<script> 
document.write('<source src="movie.mp4?'); document.write(Math.random()); document.write('" type="video/mp4">'); </script>
</video> 

 

 

Guess you like

Origin www.cnblogs.com/Minstrel223/p/10980184.html