在Symfony上使用Hinclude.js实时更改值



我关注了这些ymfonydocyoutube,通过渲染控制器,成功地创建了一个控制器和一个包含异步内容的小枝。但这只是一次改变。

在Symfony上使用Hinclude.js是否有可能在twig上实时显示不断变化的值。

如果你设置了Cache-Control header (https://odino.org/scaling-through-hinclude/),看起来这可能会起作用。

试试这个:

public function indexAction()
{
$response = new Response($this->renderView('index.html.twig', []), 200);
$response->setCache([
'no_cache' => true,
'max_age'  => 0,
's_maxage' => 0,
]);
return $response;

}

https://symfony.com/doc/current/http_cache.html more-response-methods

最新更新