Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to understand angular cache busting

I am running angular 6. When building with --prod, the scripts are generated with a name such as main.547a75c48dc342a8e291.js. I assumed that was a unique name generated each time but it seems to be the same.

How does angular CLI generate this name? Should I be giving another option to ensure that every time we do a production build it is unique?

like image 670
Scott Avatar asked Aug 28 '18 15:08

Scott


People also ask

What is cache busting in angular?

Cache busting example This means that once cached locally on the user's browser, the browser won't check the origin server again for 1 whole year to see if any updates have been made to the file.

What is the purpose of cache busting?

Cache busting is a way to prevent browsers from caching your ad content. Cache busting adds a random string to your ad tag each time the tag fires — typically a random number. Because the tag has a different number each time, the browser sends a new request each time.

How do I clear angular cache?

Angular cache There is no command to clear the cache, just run rm -rf . angular/cache .

How does angular use cached data?

Using shareReplay shareReplay helps us cache data in our apps quickly and replay the data to new subscribers. Add the shareReplay operator in the flow of data, take the data from the HTTP request, and put it into a buffer so that it can replay the last emission of my HTTP request.


1 Answers

547a75c48dc342a8e291 is a hash. If there are no changes to main the hash would be the same. By changing a file included in main, the hash will be different, and the cache will bust.

like image 189
Moshe Avatar answered Sep 25 '22 18:09

Moshe