3

Is it possibile to clear cache on sigle page using javasscript? I know that document.location.reload() will do that. But can it be done without refreshing page?

braX
  • 11,506
  • 5
  • 20
  • 33
Slavko Ilic
  • 95
  • 3
  • 7
  • Why do you think that you can control the cache? – Ed Heal Aug 16 '15 at 11:56
  • More importantly, why do you want to do it? There's possibly a better way to solve whatever problem you have. – user247702 Aug 16 '15 at 12:00
  • 1
    possible duplicate of [How to programmatically empty browser cache?](http://stackoverflow.com/questions/8155064/how-to-programmatically-empty-browser-cache) – JJJ Aug 16 '15 at 12:01

2 Answers2

2

You can do is to tell it not to cache your page, by sending the appropriate headers or using these meta tags on your HTML :

<meta http-equiv='cache-control' content='no-cache'> //clear cache
<meta http-equiv='expires' content='0'>//clear cache with some expire time
<meta http-equiv='pragma' content='no-cache'> // no Cache 
Anand Dwivedi
  • 1,452
  • 13
  • 23
-2

I can't think of a way to clear cache using Javascript. Probably you should try to append a version number to force the browser to load the new one. For example, change this:

<script type="text/javascript" src="myscript.js"></script>

to this

<script type="text/javascript" src="myscript.js?version=1"></script>
quangdng
  • 11
  • 2