Debugging Symfony2 NGINX缓存/调试工具栏
我正在尝试将varnish缓存与symfony2一起使用。 设置为Varnish->NGNIX->php fpm 我的代码:Debugging Symfony2 NGINX缓存/调试工具栏,debugging,caching,symfony,nginx,varnish,Debugging,Caching,Symfony,Nginx,Varnish,我正在尝试将varnish缓存与symfony2一起使用。 设置为Varnish->NGNIX->php fpm 我的代码: public function indexAction($city_url) { $response = new Response(); $response->setETag('foobar123fo'); if ($response->isNotModified($this->getRequest())) {
public function indexAction($city_url)
{
$response = new Response();
$response->setETag('foobar123fo');
if ($response->isNotModified($this->getRequest())) {
// return the 304 Response immediately
return $response;
}
$data = array('randA'=> rand() );
$response = $this->render('Foo:Event:index.html.twig', $data);
$response->setCache(array(
'public' => true,
));
$response->setETag('foobar123fo');
$response->setSharedMaxAge(10);
return $response;
这就像预期的那样-我得到缓存命中,但是Symfony的调试工具栏也被缓存。谁能告诉我,如何从缓存中排除工具栏?我希望看到,在为缓存结果提供服务时,实际上没有SQL查询
非常感谢 若页面完全缓存在Varnish上,则请求甚至不会命中您的web服务器。不仅没有SQL查询,而且根本没有调用Symfony 调试工具栏是页面的一部分,这就是它被缓存的原因。再一次。。。Symfony仅在第一个请求时调用 再次阅读官方文件中的章节。其中推荐了两篇文章,也值得一读: