Search code examples
phpsymfonycaching

What is warming up a cleared cache?


Can someone please explain 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 warm up the cache after bundle installation?


Solution

  • 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".