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.