i want to disable a [twig] cache for an specific Action response on Symfony2?
Is a solution to do this.
I'm not sure if I will add on response next header response will be not cached
You need to enable your auto_reload
option on Twig_Environment
. You can read about it here: http://twig.sensiolabs.org/doc/api.html
To make it with minimal efforts (and with no affect to other rendering operations) I recommend you to change this option at the moment when you want to render your Action response:
$twig = $this->get('twig');
$twig->enableAutoReload();
$twig->render('AcmeDemoBundle:Test:index.html.twig', $parameters);
It will ignore cache for all twig templates that are rendered after $twig->enableAutoReload();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.