Skip to content
Related Articles
Open in App
Not now

Related Articles

How to clear cache memory using JavaScript?

Improve Article
Save Article
  • Last Updated : 22 Dec, 2022
Improve Article
Save Article

Unlike mobile applications, a web browser doesn’t allow to clear its cache memory. Though we cannot clear all cache of the client browser it is still possible to load the webpage without caching by using meta tags in the HTML code. The only way to do this is by making few changes in the code which says the browser not remember the recently loaded memory which is nothing but the cache memory. The following are two examples that explain NOTE: The following codes cannot be run as it is and does not have an output. It has to added to an already existing code to see the Outputs. Method 1: 


<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>

Add this part of HTML code which makes the browser to not record the cache memory. Method 2: Appending a parameter to the filename in the script tag. Change it when the file changes. Example: Let this be the name of the file. Every time you load this page just change the version of the script. 


<script src = "filename.js?version = 1.0"></script>

The next time you load this page it should be something like this. 


<script src = "newfile.js?version = 1.1"></script>


  • A browser is designed in such a way that it saves all the temporary cache.
  • It is so because cache memory is the main reason for the website to load faster.
  • Hence there is no direct way to permanently delete it’s cache memory unless certain codings are changed in your HTML code.
  • There may be few other ways to achieve this, but these two are the easiest and most effective one.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!