1

I am using setInterval to call Rest API's from my web page in about every 60 seconds. Now it is making request and hogging Network with too much request due to which after sometime my page becomes slow and non-responsive.

Can anyone help me out about how to clear Network Tab cache in Dev tools without refreshing page. P.S. I don't want to clear all of Cache just the Network cache after 5 min.

Asnau Nauticas
  • 197
  • 1
  • 4
  • 20
  • May be duplicate of https://stackoverflow.com/questions/8155064/how-to-programmatically-empty-browser-cache – brk Feb 25 '19 at 09:06
  • I don't want to clear the app cache, just Network cache only. – Asnau Nauticas Feb 25 '19 at 09:09
  • 1
    I think it is same , you may not able to clear the cache – brk Feb 25 '19 at 09:10
  • Is there anything else can I do which don't hog page ? – Asnau Nauticas Feb 25 '19 at 09:15
  • 1
    how about exploring websocket? the change may be big but i think that is better. Else you can change the interval in setInterval to some higher value. Another thing you can do is use of promise. Call the rest api only when current one is done. You can check ` Promise resolve` – brk Feb 25 '19 at 09:19

1 Answers1

1

You cam use caches.delete(cacheName).

caches.keys().then(function(names) {
    for (let name of names)
        caches.delete(name);
});

But it is not supported in IE. For more details and browser supports, check here

Vikas
  • 6,868
  • 4
  • 27
  • 41