Reputation: 828
I'm using the following code to prevent a page from caching a twig random()
command.
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
?>
I am only using the random()
command on a single page, but the file that controls caching is global, is there away to target a specific file ie. default.html
? Instead of preventing caching for the entire site?
Upvotes: 0
Views: 107
Reputation: 3085
You should disable the caching on the Response object for that specific page:
$response->setPrivate()
Also see the API documentation: http://api.symfony.com/master/Symfony/Component/HttpFoundation/Response.html#method_setPrivate
Upvotes: 1