Elliot
Elliot

Reputation: 13835

Ruby page loading very very slowly - how should I speed it up?

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.

Upvotes: 1

Views: 142

Answers (2)

Elliot
Elliot

Reputation: 13835

Ok so here are the steps I've taken:

Understanding Eager Loading & How to use it? (specific issue) (implemented eager loading to cut down on SQL queries)

Only show content when certain criteria is met? (less empty content on page)

Remaking this loop by user? (perfecting the above through the models)

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

Upvotes: 0

Eimantas
Eimantas

Reputation: 49344

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.

Upvotes: 1

Related Questions