PDA

View Full Version : PHP How to write a script cache?



alexporter
10-06-2009, 08:52 AM
Hi BH fans,

I would like my site to load as fast as possible, I'm using rico to round my corners, so the longer it takes to load, the uglier it looks.

I have a dynamic menu system that requires a bucket load of queries every time the page loads. The menu does change but only maybe once or twice a day.

So does anyone have any ideas on how to write a script that will cache the menu system into plan html say once an hour

All input would be much appreciated.

thanks
Alex

Justin
10-07-2009, 08:11 AM
You can head to Codingforums.com to ask for assistance. However, my directory implements caching, but the link submitting page still loads slowly. This is due to the fact that each time a submitter clicks on the page's button, all the categories have to load on the form, and the CPU quota that Bluehost implements doesn't help. I really don't know if caching will help you, as it doesn't help in my case.

alexporter
10-07-2009, 08:20 AM
Hi Justine,
I've just found Cache_lite which is a PEAR extension, which may to the job. Have you tried using this? I've saved the output from my .php page as .html and the load time was a lot quicker. So hopefully if I can cache the menu,it will produce the same results.

alex

alexporter
10-07-2009, 08:46 AM
Me again.
I've got (i think) cache_lite to work, well the time stays the same for 10 seconds. :)

I've put a micro timer at the start and end of the <body> and it varies but generally cached thats 0.00085 and a fresh page says 0.008, so in theory a tenth of the time. BUT to me, it seemed to take longer than that, so I put the start time above the <html> tag and it now tells it, it takes between 0.008 and 0.25 seconds to load.

Another BUT coming up

But the end time is displayed before the menu is closed up(its an accordian), so actually half the page loading time is spent loading the menu and the other half is spent doing RICO stuff .:confused:

Hmmm, anyone know how to speed up the download of JS?

felgall
10-07-2009, 12:30 PM
JavaScript called directly from HTML single threads for the download and so nothing else can download while waiting for the JavaScript.

If you use a short piece of JavaScript to call larger javaScript files then that single thread limit doesn't apply because the large file was requested from JavaScript and not from HTML. It cal therefore download outside of the two or eight thread limit that the browsers have for downloading files requested from the HTML.

See http://javascript.about.com/library/bladdjs.htm

alexporter
10-07-2009, 05:58 PM
Hi Felgal,
Thanks for the input. So what your saying is run a small snippet of JS which then called Rico et al?

I've been looking at using Google CDN to serve my ajax, any thoughts on that?

Also if you think that's a good idea, does anyone know of another CDN that serves rico?

thanks again
alex

felgall
10-07-2009, 06:48 PM
I've been looking at using Google CDN to serve my ajax, any thoughts on that?

If you can reference large javaScripts from a site that a lot of other sites also use then any of your visitors who has recently visited any of those other sites will already have the javaScript cached saving the time for them to download it again.