'Clear javascript source cache laravel 5.8
I create company profile website using laravel 5.8 and vue js for make it reactive, it's not SPA(single page application) maybe we can call it hybrid, everything run well in local, after i modify javasacript locally then run a command yarn watch to compile and run my web again it runs well. let's say i have uploaded my project to shared hosting. then i modify my javascript code then re-upload my app.js code and here's a problem. the browser loads my previous app.js not my new app.js. i have cleared browser cache it's sill load the previous app.js. how to solve this problem? thanks
Solution 1:[1]
put a random number at the end of address like this:
<script type="text/javascript" src="app.js?v=12392823"></script>
Solution 2:[2]
Better option is to add .version()
to your webpack mix file:
mix.js('resources/js/app.js', 'public/js')
.version();
After that, when you call mix('js/app.js')
in your view, it will add the cache busting get parameters automatically and the parameter will ONLY change if the file has been changed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Babak Asadzadeh |
Solution 2 |