我刚刚设置了 Varnish ,并且在投入生产之前我已经在端口 8080 上做了一些测试。
我注意到,如果我在缓存页面上:
/**
* @Cache(smaxage="10800")
* @Route("/{_locale}/", name="homepage2", requirements={"_locale" = "en|fr"})
* @Template()
*/
public function indexAction()
{
return array();
}
我尝试通过
ESI
包含的组件登录(不使用外部服务,但使用正常登录) {% render "GamerCertifiedHomeBundle:Home:login" with {}, { 'standalone': true } %}
它最终将我重定向到一个没有样式且没有 URL 的页面
...:8080/_internal/secure/MyBundleHomeBundle:Home:login/none.html
Step1 Screenshot/Step2 Screenshot
如果我回到主页,我已经登录了。
请问我该如何避免呢?
编辑 :
最佳答案
分析the chat中的问题后我发现 _target_path
为安全起见,重定向以以下方式生成:
<input type="hidden" name="_target_path" value="{{ app.request.uri }}" />
由于这部分是使用独立 View 呈现的 - 它具有特定的 uri(带有 _internal
前缀)。您可以通过为
app.request.uri
应用更改的逻辑来避免这种情况。注入(inject)。 {% render yourAction with {'uri': app.request.uri}, {'standalone': true} %}
public function yourAction ($uri)
{
...
return array('uri' => $uri);
}
<input type="hidden" name="_target_path" value="{{ uri }}" />
享受吧! ;)
关于symfony - 登录 ESI 组件中的缓存页面会重定向到/_internal/secure/.../none.html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11815973/