Sometimes, we want to clear or replace a cached image with JavaScript.
In this article, we’ll look at how to clear or replace a cached image with JavaScript.
How to clear or replace a cached image with JavaScript?
To clear or replace a cached image with JavaScript, we call fetch
.
For instance, we write
fetch("/thing/stuck/in/cache", { method: "POST", credentials: "include" });
to call fetch
with the URL of image stuck in the cache by making a post request to it.
Then the image will be reloaded.
Conclusion
To clear or replace a cached image with JavaScript, we call fetch
.