I've usually loaded CSS files with PHP by adding a GET variable that changes each time. For example the value of the microtime
But I need to dynamically load a CSS file avoiding navigator cache for see the continuous changes making in production development.
<?php echo '<link rel="stylesheet" type="text/css" href="myFile.css?v='.round(microtime(true)).'"></script>';?>
Sometimes you will need to load a dynamic file name as well. It is possible to do it without PHP like this:
<link rel="stylesheet" type="text/css" href="" id="myCSS">
<script>
var microTime = Date.now();
var myVar = "myCSSFile";
var myUrl = myVar+'.css' + '?v=' + microTime;
myCSS.href= myUrl;
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.