开发者

How to reduce Rails form loading time

I have a form which has 4 associations and 2 javascript calls. It is taki开发者_JS百科ng to load minimum of 10 seconds to load,even for new form. Out of 10 seconds, Active record is taking with in 100 ms and remaining 9990ms are taking to load Views. (In views page,i am loading tiny mice editor,autocomplete javascript libraries)

Is it possible to load a page loading 4 associations,including 2 javascript libraries in less than 3 seconds? If yes, Pleas any body help me in loading my form much faster?

Thanks in Advance, Prem.


How are you measuring this load time? By timing it in the browser until the page is loaded? TinyMCE does a fair bit, and in development mode you will see that the general performance of your app could be quite slow.

To see how it really performs, deploy the application to a production environment (or create a production setup including DB on your local machine) and run the app with rails server -e production


I would suggest you to check this http://www.railsinside.com/tutorials/230-scaling-rails-a-free-13-part-series-of-screencasts.html.

As said if you have four associations you may have to do eager_loading or may be better write sql and use find_by_sql.

Regarding javascript or view loading you may have to research minifying javascript and css. You also need to consider using image sprites.


After doing all the improvements you can by writing better requests, you should consider caching. It's easy to do, the problem is that you have to manage when to invalidate the cache.

Check http://guides.rubyonrails.org/caching_with_rails.html for help on how to do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜