Your local area cable provider has been putting the concept of On-Demand to good use for years, providing television or movie titles only when specifically requested by the user. There are just too many titles out there to run them all simultaneously. The most popular and current titles are made available via traditional television channels and are always displayed on the guide.
This concept also carries over to web content. With any given page load, we could query every possible piece of relevant content from our various data sources (web files, database, external, etc), and display it all at once. But, this reveals two major problems. First, it would place an unreasonable load on our servers with each request. Second, it would overwhelm the user with the large amount of information that is spit out onto the page.
The first step to resolving this problem is knowing which pages are resource intensive.
Once you have this knowledge, it's a matter of stepping through each page, and determining where you can "cut back".
There are three basic approaches:
- Dedicate a separate page
This is the most obvious choice, and usually the simplest to implement. For less important information that happens to be resource intensive (pulls from multiple database queries or requires many calculations), placing that information on a separate page and linking to that page is a decent solution.
In terms of website maintenance, this is usually the most robust solution. However, it does require a complete page load, and additional "wait time" on behalf of the user.
This is used commonly in e-commerce, as the are many time dozens of queries involved with any given page. Instead of displaying all of the recent account information, most of the time a customer is presented with a "link dashboard" as seen in the example below:
- Use query string parameters
This is very similar to method above. I only made the distinction to identify this particular method as content on-demand.
Perhaps the most common example of this is pagination. Although we usually don't consider it in this light, pagination is a resource saver. If 90% of users will only click through links in the top 10 query results of a search, it makes sense to display only those 10 results on the first page, then force the user to click to retrieve additional results from the server if desired.
Using a Google search result for example:
The start parameter designates to Google's server which page of results to show to the user.
Using the "My Account" example as shown above, we might instead divide the information into tabs. A tab for Order History, a tab for Reviews and a tab for Wish List, for example.
As the tabs are clicked, an AJAX request for the content is made. Once that content is available, it appended to the page, and the clicked tab is shown as active by adding a CSS class.
YouTube's home page offers a great example of this (although the tabs look more like navigation controls). As you click on the navigation links, the page is not reloaded. Instead, content is loaded and applied to center content area via AJAX.