【发布时间】:2015-06-03 08:21:16
【问题描述】:
我有一个控制器,其动作在树枝中呈现
{{ render_esi(controller('MyWebsiteBundle:Element:header')) }}
Action 本身如下所示:
/**
* @return Response
*/
public function headerAction()
{
$currentLocale = $this->getCurrentLocale();
$response = $this->render('MyWebsiteBundle:Element:header.html.twig', array(
'currentLocale' => $currentLocale,
'myTime' => time()
));
$response->setPublic();
$response->setSharedMaxAge(3600);
return $response;
}
当我重新加载浏览器时,"myTime" 每次都会更改。
如何使用setShardeMaxAge(),让Twig只有在MaxAge过期后才渲染?
【问题讨论】:
-
你是用
app_dev.php还是app.php访问页面? -
目前我使用 app_dev.php
-
您是否在您的
app_dev.php(howto?) 中启用了symfony 的内部缓存代理AppCache? -
require_once DIR.'/../app/AppCache.php'; $kernel = new AppKernel('dev', true); $kernel->loadClassCache(); // 用 AppCache 一包装默认的 AppKernel $kernel = new AppCache($kernel);
-
我看到你已经接受了 Dan Revah 的回答 .. 只是出于好奇 - 你错过了答案的哪一部分?