I am doing an angular project,but after every changes in java-script file I want to clear the cache.So I want to know is there any angular code for deleting or removing the cache file?
Asked
Active
Viewed 1.4e+01k times
20
-
2maybe: http://stackoverflow.com/questions/14718826/angularjs-disable-partial-caching-on-dev-machine – vaso123 May 02 '16 at 14:45
-
[check this](http://stackoverflow.com/q/32414/492258) – asdf_enel_hak May 02 '16 at 14:49
5 Answers
9
Just move ahead with the following command
npm cache clear --force
For verifying, you can run the following command to check the contents of the cache folder, garbage collecting any unneeded data, and verifying the integrity of the cache index and all cached data.
npm cache verify

Basil
- 1,664
- 13
- 25
-
1A question can have multiple answers even though it was same. It's all about how it is being explained. – Basil Jan 28 '20 at 13:38
-
1That's why we have the edit button. If you you think you can enrich the given answer, then make a suggestion. That's how SO works – Vega Jan 28 '20 at 13:40
-
That's your way of approach, What I did was elaborated the answer in my own way and made simple – Basil Jan 28 '20 at 13:52
3
How about adding this tag to index.html ? Is this valid?
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

Carlos Cruz
- 405
- 3
- 6
-
This works for HTML changes that don't appear until after clearing cache. Here's a great article that explains it well: "For a single-page web application like Angular, index.html is like a gate for everything else. In Angular and almost all the other single-page web applications, routing happens in the front-end. Basically, by loading index.html, we are loading all the other pages too (If not lazy-load). Hence, If index.html is cached, then every other page is cached as well." http://yuezhizizhang.github.io/angular6/cache-control/2019/06/07/angular-cache-control.html – Alec Jan 15 '21 at 15:20