13

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?

ArunJaganathan
  • 621
  • 2
  • 7
  • 20

5 Answers5

18

just do this npm cache clear --force it will work

etah jet
  • 169
  • 1
  • 7
4

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,240
  • 10
  • 17
  • A 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
  • That'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
2

first

npm cache clear --force

then

npm cache verify

Fahim zuhair
  • 118
  • 5
2

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
  • 105
  • 1
  • 5
  • 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
1

1'st Step:

npm cache clear --force

2'nd Step:

npm cache verify