Symfony2中缓存的内部路由
我在项目中使用内部路由,并使用输出URL进行缓存(Varnish)。Symfony2中缓存的内部路由,symfony,varnish,Symfony,Varnish,我在项目中使用内部路由,并使用输出URL进行缓存(Varnish)。 代码: 和细枝(基本细枝)包含代码: {%render“my_controller:getHeaderAction”与{},{“standalone”:true}%} {%render“my_controller:getSidebarAction”与{},{“standalone”:true}%} {%render“my_controller:getFooterAction”与{},{“standalone”:true}%}
代码: 和细枝(基本细枝)包含代码:
{%render“my_controller:getHeaderAction”与{},{“standalone”:true}%}
{%render“my_controller:getSidebarAction”与{},{“standalone”:true}%}
{%render“my_controller:getFooterAction”与{},{“standalone”:true}%}
这将生成如下URL:/parts/my\u controller%3GetHeaderAction/none.html
/parts/my_controller%3GetSideBarAction/none.html
/parts/my_controller%3AgetFooterAction/none.html
我试图为SidebarAction获取单独的Url,如:/parts/prefix/my_controller%3GetSideBarAction/none.html
但由于内部路由自动生成URL,因此无法确定如何执行此操作。有什么解决办法吗?
谢谢您的时间。您需要手动为
my_controller:getSidebarAction
定义路由规则,然后使用url
标记进行渲染
假设您使用的是symfony2.3,语法将是
{{render_esi(url('latest_news',{'max':5}))}
请注意,我正在使用特殊的render_esi
标记,这是在Symfony 2.2中添加的,目的是为Varnish等反向代理添加更好的esi支持
更多信息请点击这里
_internal:
resource: "@FrameworkBundle/Resources/config/routing/internal.xml"
prefix: /parts