0

Super reload or cache deletion

I've been looking for a way to do it with Google Chrome for months, but I have no idea.

I'm looking for a way to super reload, how can I super reload?

By the way,

location.reload (true); Well, it's not done at all. (true) has no meaning at all.

window.location.href = window.location.href;

location.reload (); return false;

Is not done in the same way.

According to some people, the function itself has been abolished, but can anyone explain in an easy-to-understand manner why the following extensions allow super reloading? Chrome Hard refresh extension

Chrome Super Reloader extension

What is the reason why extensions can do it, but user scripts and bookmarklets can't?

Just in case, again, I'm looking for a way to do it with Google Chrome.

// I want to do it with the "F5" key.
(function() {
  "use strict";
  document.addEventListener ('keydown', function (e) {
    if (e.keyCode === 116) {
      window.location.href = window.location.href; // unexploded
      location.reload (true); // unexploded
      // unexploded
      chrome.browsingData.removeCache ({});
      chrome.tabs.reload (arrayOfTabs [0] .id);
      setTimeout (function () {
        location.reload ();
      }, 2000);
    }
  });
})();

Supplement:

The difference between reload and super reload is You can also see the difference on the stackoverflow.com/ site.

When the code is no longer colored, the F5 key alone will not solve it,

Press the CTRL + F5 keys to cancel.

Rojo
  • 2,749
  • 1
  • 13
  • 34
just a passerby
  • 103
  • 1
  • 1
  • 10
  • 2
    F12 -> Network Tab -> Disable Cache – Thomas Mar 27 '21 at 22:30
  • If you just want the page to load without using the cache, you can call the page with a dynamic querystring that is different each time you call it (using a timestamp is best). The server will believe that it is a new page that hasn't been cached before and therefore will load without the cache. See https://stackoverflow.com/questions/9692665/cache-busting-via-params for details. – Scott Marcus Mar 27 '21 at 22:44
  • @ScottMarcus you are mistaking here `serverside caching` and `browserside caching`. The browser cache does not care if you change a url parameter. – Michael Walter Mar 28 '21 at 04:44
  • @MichaelWalter No, I'm not. If the URL is different than any that has already been accessed, the ***browser*** will see it as a new file and download it without using the cache (the browser ***does care***). The resource URL's ***within*** that document would not have changed though, so images and other resources that have static URLs in the file will utilize the cache, but the main file won't. – Scott Marcus Mar 28 '21 at 16:42
  • @ScottMarcus you are right, my mistake – Michael Walter Mar 28 '21 at 23:19

1 Answers1

1

Browser extensions have special permissions that webpage scripts will never get. Webpages are not supposed to edit information that they haven't made. Extensions/add ons have that ability since every extension is reviewed by a human and a robot. Together, they make sure extensions don't do anything malicious. Imagine trying to do that for every webpage in the world!

However, the server can control what is and isn't cached using headers. Here's a list of different servers' header-setting methods

You can set cache-control headers in HTML, too. You can do something like <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> in the head.

Javascript can control cache for files it fetches.

Rojo
  • 2,749
  • 1
  • 13
  • 34
  • Should I do this when inserting with Javascript? ``` window.addEventListener('load', e => { document.getElementsByTagName('head') .insertAdjacentHTML ('beforeend',` `); }); ``` – just a passerby Mar 27 '21 at 23:53
  • Well, you can just add that tag into the `head` with pure HTML, no JS required. It will automatically apply to any Javascript fetching you do – Rojo Mar 28 '21 at 00:00