Is there a way to force a browser cache refresh?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2018 11:25 AM
Some of my client/UI scripts are stale whenever we deploy to production, breaking some of our data-filling automation. If there's an easy way to flush the user's browser cache through a simple script or some other mechanism, that would make deployments are lot smoother.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2018 11:40 AM
Have you tried flushing cache when none of the users are logged into the system ?
Alternatively Users can try Ctrl+R to reload the page from Server.
Best Regards,
Rahul
Please mark the thread as Correct / Helpful if it resolved your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2018 11:49 AM
The issue is on the client side is the thing. I don't know exactly what happens under the hood, but client and UI scripts get saved to a user's browser, so any updates we've made to those script are ignored.
Our best solution right now is just telling users to clear their browser caches whenever we deploy a patch, but that's not ideal because some folks might miss the email, etc.
One potential solution I've considered is having a UI or client script that runs independently that refreshes the browser cache, but I'm not sure if there's a standard call to do that. I suppose there's something built into javascript that could refresh a browser cache.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2018 01:40 PM
Either give the UI script a different name when making changes to it or when you call it do something like this
ScriptLoader.getScripts(('yourUIScriptname.jsdbx?'+ new Date()), function() {
.....
});
The above will force the browser to download the latest UI script code
Thanks,
Miguel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2019 02:17 AM
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.