how to clear browser cache and history via javascript I found some links like:-
How to clear browser history oan clear cache?
how to clear browser hash history in javascript
but they do not properly described on how this can be achieved via javascript ( or jQuery)
I require this so that the user do not have to do a [Ctrl+F5] or manually clear cache and the most recent version of javascript file is loaded in the browser.
The main aim is to load the latest javascript files every time the user visits the website. My application in ASP.NET MVC based and javascript files are included in .csHtml file.
There are other ways to prevent a JavaScript file (or other files) from being cached.
Simply append some dummy parameters to the end of the url. For example -
You would optimally do this on the server side. In PHP, this would look something like this -
Using the
time()
function, we append the current epoch timestamp to the URL and therefore guarantee* that the file will appear different to the browser each time.* Until 2038 that is ;)
call
window.location.reload(true)
for actrl+F5
from script. :)