Entry
How can I improve the performance of my very large site?
I have a lot of include()'d code, how can I improve performance?
Aug 10th, 1999 22:57
Nathan Wallace, Jacob Stetser
Try using _conditional includes_ and only include what you need for
any particular page. I did this and speeded up a script of mine that
was running into about 2-3,000 lines of code.. it was usually running
between 1-4 seconds per page, and now it runs between .1-.9 sec per
page. I instituted a caching system and pages that are cached take
about 2-3 THOUSANDTHS of a second per page PHP execution time! (I
still use PHP to determine whether to serve a cached page or a real
page, but the script is only about 150 lines total before I call an
exit(); if it serves a cached page.
I don't have any real world testing of how this affects server load,
but I have a feeling that PHP does better the less code you give it
at a time, and that caching pages, if it can be done, can make
a script incredibly light when it comes to server load.
Example of conditional include
if($action=="buystock") {
include("./includes/buystock.inc");
} elseif(....) {
include("....");
} etc...