views:

71

answers:

3

Hey guys,

I'm going to try and describe the code in my view, without actually posting all the garbage:

It has a standard shell (header, footer etc. in the layout) this is also where the sub navigation exists which is based on a loop (to find the amount of options) - on this page, we have 6 subnav links.

Then in the index view, we have a 3rd level nav - with 3 links that use javascript to link/hide divs on the page.

This means each of those original 6 options, all have their own 3'rd level nav, with each of their own 3 div pages.

These three pages/divs have the input form for creating a record in rails, and then the other 2 pages show the records in different assortments.

ALL of this code lives on one page (aside from the shell). The original sub nav uses a javascript tab solution, to browse through all of it... (this means its about 6 divs, which all contain 4 divs of function - so about 24 heavy divs).

Loading it seems to take forever, although after loaded its extremely fast (obviously).

My big question, is how should I attack this? I don't know ajax - although I imagine it'd be a good solution for loading the tabs when clicked.

Thanks!

Elliot


UPDATE:

So I don't think caching the pages is actually going to accomplish much... I have 84 loops which call records in the page (its currently 84 as there are 7 main menu item - added one more since original post, each menu item has 3 pages, within those three pages there are about 12 lists of items, and because it all lives on one page - 7x12 = 84 loop/lists...Each time I decide to add a main menu item, it will add 12 more loops/lists to the page). And they can't be cached as they themselves are dynamic.

I feel like there needs to be some type of progressive loading solution in existence, where the tab only loads the data when clicked?


I've been doing a number of things to speed up the page, all of which I will post in an answer upon completion.

+1  A: 

Try fragment caching for those menu items. I believe the menu is being fetched from sql (category list browsing). Other than that - garbage would help diagnose your problem more accurately.

Eimantas
A: 

Do what Elimantas said plus look at these Railscasts: http://railscasts.com/tags/18

and these ajax related railscasts:

http://railscasts.com/episodes/169-dynamic-page-caching

http://railscasts.com/episodes/43-ajax-with-rjs

DJTripleThreat
A: 

Ok so here are the steps I've taken:

http://stackoverflow.com/questions/2865310/understanding-eager-loading-how-to-use-it-specific-issue (implemented eager loading to cut down on SQL queries)

http://stackoverflow.com/questions/2870629/only-show-content-when-certain-criteria-is-met (less empty content on page)

http://stackoverflow.com/questions/2878689/remaking-this-loop-by-user (perfecting the above through the models)

The page is much faster now, hopefully these resources help someone else too!

Elliot