views:

357

answers:

2

Hi,

I'm working on a rails project and I experienced that the response to ajax calls are slow in both development and production. Response comes around 8 sec. I observed also that i have some actions that has a response time around 80ms. The difference in the two acitions is that the slower was rendered using render :update do |page| ... end The fast one was rendered using rjs template. Somebody had similar experiences? Another problem is that i cant use rjs in any time, because there are actions which only gives a html/text response and not javascript. for example i'm using render :inline, render :text, render :nothing. These methods cannot be turned into rjs I think.

Ok, sorry for not providing code. 1st version: http://pastie.org/749000 This takes 8second. 2nd version: http://pastie.org/748997 This takes 80millisecond.

Also I have to mention that i'm using the community engine plugin, and this problem happens in the production machine. In development both version takes around 4 sec.

+1  A: 

Without seeing some code it's difficult to help you out on this one - I would suspect that whatever the action does that is taking a long time is what is causing the response to be so long (querying the database, etc.)

smnirven
I tried all the ajax calls in the site and all of them reacts like i described above.
dombesz
A: 

smnirven is probably right in his assessment that it's probably a database action taking a long time.

render :update do |page| should not cause any performance issues over using an RJS template. It's pretty much exactly what happens when you render an RJS template implicitly.

As for your inability to use RJS... You can use it on any remote function call, just be sure to remove the :update option from the link_to_remote. Providing the :update option makes the request expect HTML. If you remove the :update function the request expects javascript to be executed on its return to the browser.

Any options you can pass to render can also be passed to page.insert_html or page.replace_html in either an RJS file or render :update.

EmFi
Yes you're right with :update, but i'm using some plugins like in_place editing which i dont really like to modify. But anyways i agree that the slowness problem comes from elsewhere. I'm not familiar with caching but, it could be a caching problem? Like when I use rjs belongs to views and it is cached and when just using in controllers cannot be cached. Am i right? This could be a problem?
dombesz
I don't have much experience with caching so I can't comment.
EmFi