Link to home
Start Free TrialLog in
Avatar of greenerpastures
greenerpastures

asked on

How to store and retrieve a heavy page

I have 2 very slow pages on my real estate site that use several Joomla components, lots of RSS and images, so it take over 2 minutes to load those 2 pages as there are way too many HTTP requests. Is there a script out there (prefer PHP) that stores a page, say every hour, and fetches it quickly from memory without running all the scripts on the page each time the page is loaded?
Avatar of Gary
Gary
Flag of Ireland image

Have you got caching enabled?
http://docs.joomla.org/Cache
Avatar of greenerpastures
greenerpastures

ASKER

Yes. I am using Joomla 1.0 site that has several custom components (hence it is very hard to move to the latest Joomla). The site though works very well, except the two heavy pages--which I believe do not use Joomla caching because they they are not part of Joomla core components. THat's why I am looking for an outside script for caching that is not part of Joomla.
But the full page caching should still work as it is based on the url.
Some things like RSS you will not be able to affect as they are dynamic.
What exactly are the http requests - is this all dynamic stuff (ajax)?
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ray,
I got it working very nicely with your code, the page loads in a few seconds! A few questions...
1. How would I set up the cron job to update the page each hour? I am a little confused as to what triggers the page saving and which page do I point the cron to?

Let's say I have: slow-page.html and fast-page.html

Is there some default PHP setting at which the page will refresh on its own?

2. Can you elaborate on "You may want to change the way the $uri variable is set."?
If the script works and creates the fast-page version, you've already taken care of #2.

For information on how to set up the CRON job, contact your hosting company.  They almost certainly have an example or tutorial.  It's a little different from one installation to another.
Is there some default PHP setting at which the page will refresh on its own?
No, but you're on the verge of a really good idea.  Every file comes with the ability to identify when it was last written to.  Get the current time from time() and use this function to find out how old the file might be
http://php.net/manual/en/function.filemtime.php 

You can make some kind of rule, like if the times are more than an hour apart, go with the slow-page version to create the latest fast-page version.
So it looks like my new fast-page.htm "wants" to refresh every 2 minutes or so, which is way t0o soon. Any way to adjust your code so that it saves the page for 30 minutes? Otherwise, every 2 minutes or so the page becomes very slow.
... "wants" to refresh every 2 minutes ...
How is it expressing its want?  Is there some programming you can show us so we can see what is triggering the refresh?  Are you doing this with CRON or filemtime()?
None. If I keep physically refreshing my browser every 20 seconds or so then I notice that in about 2 minutes the page will stall, slowly reload, and then become fast again loading again.

A cron for every 2 minutes would I think use too much of system resources.
I'll need to see the code that makes the decision whether to load the fast page, or rebuild the fast page before producing the browser output.  Without that, I'm just guessing, and there isn't enough time left in life to guess about things that can be observed and finitely determined.
Thanks for the points and thanks for using EE, ~Ray
Thank you, Ray. You have helped me a lot on several occasions.

After looking at my file structure, I noticed that your code above is actually producing a brand new page with .html extension (in addition to the .php page). So I created the cron job for the .php page and directed the users to .html page--problem solved.