我对Symfony 1.4和AJAX有速度上的问题。
My路由:
ajax_search:
url: /search.:sf_format
param: { module: article, action: articlesAjaxSearch, sf_format: html }
requirements:
sf_format: (?:html|js)My js:
jQuery.ajax({
type: 'GET',
url: jQuery('#searchform').attr('action'),
data: form_data,
success: function(result)
{
jQuery("#searchform #searchresult").html(result).slideDown('fast');
}
});我的行动:
public function executeArticlesAjaxSearch(sfWebRequest $request) {
$this->getResponse()->setContent("<html><body>Hello, World!</body></html>");
return sfView::NONE;
}这是一个较短的版本,但我需要提高速度。AJAX调用需要大约200 ms才能取回这个HTML内容。
这是我的日志:
Sep 05 09:25:58 symfony [info] {articleActions} Call "articleActions->executeArticlesAjaxSearch()"
Sep 05 09:25:58 symfony [info] {sfWebResponse} Send status "HTTP/1.1 200 OK"
Sep 05 09:25:58 symfony [info] {sfWebResponse} Send header "Content-Type: text/html; charset=utf-8"
Sep 05 09:25:58 symfony [info] {sfWebDebugLogger} Configuration 0.88 ms (8)
Sep 05 09:25:58 symfony [info] {sfWebDebugLogger} Factories 53.19 ms (1)
Sep 05 09:25:58 symfony [info] {sfWebDebugLogger} Action "article/articlesAjaxSearch" 115.39 ms (1)
Sep 05 09:25:58 symfony [info] {sfWebDebugLogger} Database (Doctrine) 0.01 ms (3)
Sep 05 09:25:58 symfony [info] {sfWebDebugLogger} View "None" for "article/articlesAjaxSearch" 0.00 ms (1)
Sep 05 09:25:58 symfony [info] {sfWebResponse} Send content (39 o)我需要一个解决方案来提高symfony 1的ajax请求速度。
Sep 05 09:25:58 symfony [info] {sfWebDebugLogger} Action "article/articlesAjaxSearch" 115.39 ms (1)我不明白为什么要花这么长时间。希望有人能帮我解决问题,我希望有一天能找到更多的答案。
ajax请求的整个时间为200 of,没有实现逻辑。
发布于 2013-09-05 07:50:19
我建议:
public function executeArticlesAjaxSearch(sfWebRequest $request) {
// ...
echo json_encode($answer);
exit;
}您可以将模块放入单独的应用程序中,并禁用不必要的过滤器。您还可以使用单独的环境和禁用,或者对工厂使用更快的实现。
https://stackoverflow.com/questions/18630399
复制相似问题