No cache for specific TWIG Symfony2 page
1 answer
You need to enable the parameter auto_reload
on Twig_Environment
. You can read about it here: http://twig.sensiolabs.org/doc/api.html
To do this with minimal effort (and without affecting other rendering operations), I recommend that you change this parameter at the moment you want to respond with Action:
$twig = $this->get('twig');
$twig->enableAutoReload();
$twig->render('AcmeDemoBundle:Test:index.html.twig', $parameters);
It will ignore the cache for all branch templates that appear after $twig->enableAutoReload();
+2
source to share