whiteletters in blankpapers whiteletters in blankpapers - 3 months ago 13
PHP Question

What is warming up a cleared cache?

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
.


Why to clear the cache during bundle installation? And why to warmup? Your usual explanations are greatly precious.

Answer

The purpose is to initialize any cache that will be needed by the application and prevent the first user from any significant “cache hit” where the cache is generated dynamically.

from http://symfony.com/doc/current/reference/dic_tags.html#kernel-cache-warmer

Real world example: you give some stats that need to be cached so you can write your own service that will be called onto kernel.cache_warmer event to perform this task "statically".

Comments