Skip to main content
removed unsubstantiated opinion, copyedit
Source Link
Andrew T.
  • 16.5k
  • 10
  • 76
  • 127

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.

I need a way to clear the current cache or all cache from the same origin domain via javascript, so i can make sure the update rollout of my webapp arrives without errors.

I also had no success on temporarily changing the cache meta tags in the html header.

Only on desktop and not automatable:

ctrl + R

used to work to force reload to clear the cache.

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.

I wrote my own workaround forceReload() function that works on windows Chrome and android Chrome and chromium:

window.forceReload = function(){
    if( !window.fetch)return document.location.reload( true);
    var els = document.getElementsByTagName( "*");
    for( var i = 0; i < els.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 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.

I need a way to clear the current cache or all cache from the same origin domain via JavaScript, so I can make sure the update rollout of my web app arrives without errors.

I also had no success on temporarily changing the cache meta tags in the HTML header.

Only on desktop and not automatable: Ctrl + R. Used to work to force reload to clear the cache. Now you have to press Ctrl + Shift + R or Shift + F5.

I wrote my own workaround forceReload() function that works on Windows Chrome, Chrome for Android, and Chromium:

window.forceReload = function() {
    if (!window.fetch) return document.location.reload(true);
    var els = document.getElementsByTagName("*");
    for(var i = 0 ; i < els.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 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.

Source Link
sax
  • 11
  • 1

I need a way to clear the current cache or all cache from the same origin domain via javascript, so i can make sure the update rollout of my webapp arrives without errors.

I also had no success on temporarily changing the cache meta tags in the html header.

Only on desktop and not automatable:

ctrl + R

used to work to force reload to clear the cache.

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.

I wrote my own workaround forceReload() function that works on windows Chrome and android Chrome and chromium:

window.forceReload = function(){
    if( !window.fetch)return document.location.reload( true);
    var els = document.getElementsByTagName( "*");
    for( var i = 0; i < els.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 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.