3

I enabled ESI for my symfony project and try to serve my home page marked as public which includes a private fragment.

Home page controller:

$response = $this->render("myMainBundle:Page:home.html.twig", $data);
$response->setSharedMaxAge(60*60); //cache for 1 hour
return $response;

Home page view:

{{ render_esi(controller('myMainBundle:Esi:homeHeaderNavigation')) }}

ESI controller:

$response = $this->render("myMainBundle:Esi:home_header_navigation.html.twig");
$response->setPrivate(); //no not cache
return $response;

Locally in debug mode my home page gets served with embedded content, but the response is marked as public, even if the included fragment is marked as private. Shouldn't it be private?

Tobias K.
  • 286
  • 1
  • 3
  • 11
  • No, setting a shared max age also marks te response as public, so intermediary caches can in fact cache the response. It makes no sense to mark something with an s-maxage as private. – Gerry Feb 23 '15 at 10:45
  • 1
    Hm...maybe I misunderstood something. I try to cache my home page content (static) and include the header bar dynamically since it contains the users name. But if the (aggregated) response is public, other caches (maybe client-side) will cache it too. Will intermediary caches like varnish remove the public-header so that no other client-side caches will be used? – Tobias K. Feb 23 '15 at 11:05
  • You can either tweak the cache headers, and set the max-age to 0, and leave the s-maxage at an hour, or maybe you could manipulate the headers in Varnish, and even completely disable caching from there on. – Gerry Feb 23 '15 at 11:34
  • Tobias, I have the same problem and I don't know how to fix this. Did you find any solution ? – skonsoft Apr 03 '15 at 12:15
  • Well, I don't really "solved" my problem, since I think mainly it based on a wrong understanding of ESI concepts. ESI just "glues" the page together, so the processed page can not be public including a private element.Now I just serve all responses as public not including any personal information and load them using JavaScript. This makes life a lot easier...at least for me. – Tobias K. Apr 15 '15 at 14:23

1 Answers1

0

i use hinclude (symfony docs), so i can do this

{{ render_hinclude(controller('...')) }}

and have different caching rules for each route.