Twig-output caching

I'm new to Twig and love this, but I have one problem right now. I can not find the right solution for output caching. I have several templates that require heavy database usage and need to be cached for several minutes.

But I can’t find the right solution, because I always did fast and dirty caching and I want to find a clean solution.

+4
source share
1 answer

Twig is only a template engine and does not provide a caching system as you want.

You need to cache the whole query (controller with heavy database queries + template rendering).

If you are using Silex , HttpCacheServiceProvider is what you want.

If you use Symfony 2 or want to use the Symfony HttpKernel component, this may interest you.

+2
source

Source: https://habr.com/ru/post/1400463/


All Articles