22

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?

2

5 Answers 5

32

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

Sign up to request clarification or add additional context in comments.

Comments

8

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

3 Comments

A question can have multiple answers even though it was same. It's all about how it is being explained.
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
That's your way of approach, What I did was elaborated the answer in my own way and made simple
3

first

npm cache clear --force

then

npm cache verify

Comments

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" /> 

1 Comment

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." yuezhizizhang.github.io/angular6/cache-control/2019/06/07/…
3

1'st Step:

npm cache clear --force

2'nd Step:

npm cache verify

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.