symfony3 ESI privateCache transformed to publicCache

52 Views Asked by At

I am using the symfony reverse proxy for cache.

I have 2 privates caches. You can imagine it as a private online-shop: the list of items is my first private cache because of the needed authentification of the user. the component is my second private cache because it contains dynamic data, for the logged user only.

AppKernel

$kernel = new AppKernel($env, $debug);
$kernel->loadClassCache();
$kernel = new AppCache($kernel); //  <-- enable cache

config.yml

framework:
    esi:       { enabled: true }
    fragments: { path: /_proxy }

page.html.twig

<header>{{  render_esi(controller('AppBundle:Menu:displayMenu')) }}</header>
<main>cached private stuff</main>

PageController - IndexAction:

    $response = new Response();
    $response->setPrivate();
    $response->setMaxAge(180); // 3 minutes for the content
    return $this->render('page.html.twig', [], $response);

MenuController - DisplayMenuAction:

    $response = new Response();
    $response->setPrivate();
    $response->setMaxAge(10); // only 10 second for the menu
    return $this->render('page.html.twig', [], $response);

In prod environement, it display in the cache header

Cache-Control:max-age=0, public, s-maxage=15

I have 2 private caches, why the cache header is sent as public?

Edit:

When I comment the esi_render tag, the page has its cache private with 3 minutes. (as expected)

I have check I have no other listener with the command bin/console debug:container --tag=kernel.event_subscriber

0

There are 0 best solutions below