Clear Cache Memory Using JS

Like the mobile apps, the browser will not let us clear its cache memory. But it is possible, there are 2 ways, Using them We can load our web page without caching on the client’s browser.

Method 1: Using HTNL Tags

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

Add the above meta tags to your page. Using it browser will stop recording the cache memory.

 

Method 2: Using Javascript Tags

In this method, we need to append one parameter to the filename in the script tag. And every time, you make changes in the file then you have to change that parameter as well.

Before any changes

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

After changes

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

 

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories