Clearing browser cache through script

Ashok10
Mega Expert

Hi there,

Is there a way to clear the browser cache through script instead of loading 'cache.do' page manually. Can somebody please help me on this?

Thanks

10 REPLIES 10

One way to programmatically prevent browser cache for an Ajax call is to append Date.now() or Math.random() to the request so it appears "new" to the browser, although I'm not sure if this is applicable in your case.



Hope this helps.



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

Winner of November 2016 Members' Choice Award


I have seen that you can use the following to reload a page and to ignore the cache.



Maybe try to find a way to use it in a script?



location.reload(true);



There is also commands you can use to block caching, but it is HTML and in the headers.


Check out my Consultant's Survival Guide
https://youtube.com/watch?v=zYi8KhP9SUk

Yes, John, these are the headers you can set on the server-side (e.g., processor) to prevent caching - I'm not sure if Sai has access to the server or if this may cause performance issues in other areas, though:



  // disable page caching to avoid stale results


  g_response.setHeader('cache-control', 'no-cache');


  g_response.setHeader('pragma', 'no-cache');


  g_response.setHeader('expires', '-1');


Is there a way to check whether a specific browser extension's is installed or not from Knowledge article is viewed?


Thanks for your reply John.I have tried "location.reload(true);" already,still few gauges on homepage showing the previous data.