0

It is makes sense to you ESI for user menu?

My main page in cached with s-maxage:

    $response = $this->render('MySiteBundle:Welcome:index.html.twig');
    $response->setSharedMaxAge(600);
    return $response;

Where i include by ESI user menu:

{% render 'MySiteBundle:Site:userMenu' with {}, {'standalone': true} %}

User menu is differ for signined users and not.

    $response = $this->render('MySiteBundle:Site:userMenu.html.twig');
    $response->setPrivate();
    return $response;

Is it makes sense to use ESI for this?

John Smith
  • 209
  • 2
  • 8

1 Answers1

0

Yes this is how I do on all my websites !

Otherwise, people will share the menu of the first one that hit it... They will see a bad login etc ...

By the way, be carefull Symfony 2.1 has currently some trouble if you cache your main action with shared cache and then if you used an ESI inside (with standalone true), even if it's logical ! The bug doesn't exist with Symfony 2.0, I hope it will be quicly fixed ! https://github.com/symfony/symfony/issues/6227

Sybio
  • 8,565
  • 3
  • 44
  • 53
  • Thanks! What about $response->setMaxAge(10); $response->setPrivate(); in user menu action? – John Smith Dec 15 '12 at 08:41
  • Not logic, you shouldn't use cache on your user menu, otherwise the same will be shared with all users for 10 seconds ! – Sybio Dec 15 '12 at 11:02
  • By optimizing your queries, you should not have more than 2 SQL queries on all your website if the user is logged and when all your ESI are fresh: SET NAMES UTF8 if you use UTF8 on your database, and the select of the user ! – Sybio Dec 15 '12 at 11:07