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

Pavani Ponnada
Kilo Contributor

Hello,

We can clear the cache by writing a simple UI script and by calling a script include with the  "gs.cacheFlush();" in it. Providing a sample code for reference.

 

Script Include:

clearCacheOnLoad: function()
{
if(!gs.hasRole('admin')){
gs.cacheFlush();
gs.info("cache cleared for non-admins");
}

},

UI Script code:

var ga = new GlideAjax('call script include with its name here');
ga.addParam('sysparm_name', 'clearCacheOnLoad');
ga.getXML();

 

Note: UI script runs every time a form loads in the instance.