reducing overhead of index.php loading

dvanhorn <[email protected]> Mon, 19 Jan 2004 12:46:46 -0500
Newsgroups gmane.org.ballistichelmet.devel
Message-ID <[email protected]>
Previously I had something like <?php system("./latestheads"); ?> in the
index.php file.  This meant that **each time the page was loaded**, mzscheme
was fired up, loaded it's XML library and parsed the heads RSS file before
spitting out the HTML of the latest posts.  This was a considerable amount of
overhead, so I decided to run the RSS->HTML program only when the RSS file is
updated, ie when the crontab runs the mmrss program. I replaced the system
call in index.php with <?php include 'latestheads.html' ?> which has next to
zero overhead.  The latestheads program is now in the local/bin and the
crontab looks like:

0,10,20,30,40,50 * * * * /home/bh/local/bin/mmrss
0,10,20,30,40,50 * * * * /home/bh/local/bin/latestheads >
/home/bh/local/www/latestheads.html

The page load time is noticably faster.  I don't know if cron will run these
jobs sequentially or in parallel.  If in parallel we could see a problem with
the RSS file being only partially written when latestheads starts to read it,
but we'll just have to wait an see.  If so, just add 1 minute to each interval
for the latestheads cron line.

David