duanbei1903 2013-09-05 07:35
浏览 39
已采纳

Symfony1提高了AJAX的动作速度

I have a speed issue with Symfony 1.4 and AJAX.

My routing:

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');
    }
});

My action:

public function executeArticlesAjaxSearch(sfWebRequest $request) { 
          $this->getResponse()->setContent("<html><body>Hello, World!</body></html>");

            return sfView::NONE;

    }

This is a shorter version, but I need to improve speed. The AJAX call need around 200 ms to fetch this HTML content back.

Here's my log:

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)

I need a solution to improve my ajax request speed for symfony 1

Sep 05 09:25:58 symfony [info] {sfWebDebugLogger} Action "article/articlesAjaxSearch" 115.39 ms (1)

I don’t understand why this take so long. Hope anyone can help me out I searching for more then one day for a solution.

The whole time of the ajax request take ~200ms without implement logic.

  • 写回答

1条回答 默认 最新

  • dongya9904 2013-09-05 07:50
    关注

    I would suggest just:

    public function executeArticlesAjaxSearch(sfWebRequest $request) {
      // ...
      echo json_encode($answer);
      exit;
    }
    

    You can put the module into separate application and disable unneeded filters. You can also use separate enviroment and disable, or use faster implementation for factories.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。