3

我为我的 symfony 项目启用了 ESI,并尝试为我的主页提供标记为公共的服务,其中包括一个私有片段。

主页控制器:

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

主页视图:

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

ESI 控制器:

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

在本地调试模式下,我的主页使用嵌入的内容提供服务,但响应被标记为公共,即使包含的片段被标记为私有。不应该是私人的吗?

4

1 回答 1

0

我使用hinclude (symfony docs),所以我可以这样做

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

并且对每条路由都有不同的缓存规则。

于 2015-11-09T20:44:57.403 回答