I need a way to clear the current cache or all cache from the same origin domain via javascriptJavaScript, so iI can make sure the update rollout of my webappweb app arrives without errors.
I also had no success on temporarily changing the cache meta tags in the htmlHTML header.
Only on desktop and not automatable:
ctrl + R
used Ctrl + R. Used to work to force reload to clear the cache.
now Now you have to press
ctrl + shift + R
or
shift + F5
It seems like chrome made it difficult to clear the cache.
They probably do this to cheat in browserspeed benchmarks. VW Style Ctrl + Shift + R or Shift + F5.
I wrote my own workaround forceReload()forceReload()
function that works on windowsWindows Chrome and android, Chrome for Android, and chromiumChromium:
window.forceReload = function() {
if( (!window.fetch) return document.location.reload( true);
var els = document.getElementsByTagName( "*");
for( var i = 0;0 ; i < els.length;length ; i++){
var src = "";
if( (els[i].tagName == "A") continue;
if( (!src && els[i].src) src = els[i].getAttribute( "src");
if( (!src && els[i].href) src = els[i].getAttribute( "href");
if( (!src) continue;
fetch( src, { cache: "reload"});
}
return document.location.reload( true);
};
This function will only reload contents that have been loaded on the current page, you. You can trigger it once on each of your clients after new updates are on the server, or simply add a working refresh button on your app.