Symfony2 homepage HTTP cache validation and independently ESI

576 views Asked by At

I'm designing a project which has the same structure as a blog with Symfony2.

My home displays articles and have a sidebar where there are links to login, or links to our account if we are logged.

My sidebar is an ESI, my question: If I set a validation cache on my homepage (depending on the updated date of my last article), does the sidebar will display its content independently of this cache ? Otherwise, is there another solution to do this ? (Setting articles list as an ESI, but is that ESI can have a validation cache ?).

Thank you for your answers

1

There are 1 answers

0
Vitalii Zurian On

Yes, it is possible to have parts of page cached independently. It can be implemented by setting different headers to $response:

$response->setPublic();
//or
$response->setPrivate();
//or 
$response->setSharedMaxAge(600);

The detailed answer for your question can be found at this Symfony2 documentation page.