Reputation: 9552
I have a Symfony2 page that I want to cache:
$response = $this->render(...);
$response->setMaxAge(15*60);
return $response;
Now on that page I am showing the username
(if logged in) or the login button if not logged in. Now when that page is called and I'm logged, logout and go back to that page, the username
is still displayed.
How can I prevent this behaviour while still having cache enabled for the body of the page?
Upvotes: 0
Views: 319
Reputation: 493
This is best accomplished using ESI.
http://symfony.com/doc/current/book/http_cache.html#using-esi-in-symfony
You can cache parts of a page separately with ESI.
Upvotes: 3