I’m new to Twig and like it, but i’ve got one problem right now.
I can’t find a proper solution for the caching of the output. I have some templates that need heavy database use and should better be cached for some minutes.
But i can’t figure out a proper solution because i always did quick and dirty caching and want to find a clean solution now.
Twig is only templating engine and do not provide a cache system like you want.
You need to cache the whole request (controller with heavy database queries + template rendering).
If you use Silex the HttpCacheServiceProvider is what you want.
If you use Symfony 2 or want to use the Symfony HttpKernel Component, this can interest you