Can someone please explain in newbie words what is the meaning of warming up
a cache after clearing it?
In Symfony2, there is a command that allows clearing the cache:
php app/console cache:clear
But sometimes while installing some bundles, the installation tries to clear the cache and when failed, it throws a warning saying:
Cannot clear cache with
--warmup
.
And why to warmup the cache after bundle installation? Your usual explanations are greatly precious.
Warming up the cache involves artificially filling the cache so that real visitors always have cache access. Essentially, it prepares the cache for visitors (hence the term 'warming', as in warming up a car engine) rather than allowing the first visitor to be served a cache miss.
Cold cache: When the cache is empty or has irrelevant data, so that CPU needs to do a slower read from main memory for your program data requirement. Hot cache: When the cache contains relevant data, and all the reads for your program are satisfied from the cache itself.
Cache warming is to generate new cache for your application. So when a user requests to open a page of your app, it can read data from the generated cache and give it back in return.
Cache cleaning is literally cleaning the old cache. If you do cache cleaning and not warming up, when a new request come, the application will do all the jobs it needs to retrieve data and to generate new cache and then return the result. If cache has been warmed up before that, then it will be directly returned, so it would be much faster response.
When installing a new bundle.. You install a new bundle to use it then in your app. So you do changes to source code like registering the bundle as a service, calling that service from your controllers for example and this kind of things. But the cache that was previously generated doesn't know about those changes. So cache should be cleaned and generated again (warmed up) to take the changes in mind. Not a deep answer I guess, but trying to give it a simple explanation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With