Symfony Ajax Response 显示缓存头 [英] Symfony Ajax Response displays cache header

查看:24
本文介绍了Symfony Ajax Response 显示缓存头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 ajax 响应中,Cache-Control Header 显示在标记中.

In my ajax response the Cache-Control Header is displayed in the markup.

HTTP/1.0 200 OK 缓存控制:无缓存日期:2012 年 10 月 11 日星期四格林威治标准时间 09:00:59

HTTP/1.0 200 OK Cache-Control: no-cache Date: Thu, 11 Oct 2012 09:00:59 GMT

我希望标题在标题中而不是在标记中.

I expected the header to be in the headers and not in the markup.

这是我的控制器操作摘录:

Here is my controller action excerpt:

...
$template = $this->render('list.html.twig', array(
                'data' => $data
                    ));
return new Response($template);
...

这是为什么,我怎样才能让它消失?

Why is this and how can i make this disappear?

推荐答案

方法 render() 显示标题.

您可以使用方法 renderView().此方法不显示标题,仅生成 html.

You can use method renderView(). This method don't display headers, just the generate html.

希望对你有帮助.:)

这篇关于Symfony Ajax Response 显示缓存头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆