How do you calculate the burden a bit of code is likely to put on the server? Extra points for free and easily understood.
I'm webmaster of a ~100 page site with every page containing a sidebar. The sidebar has buttons on it which either link to that page if you're not on it or put a CSS class on the text if you are.
I'm in process of updating and streamlining the site. I'd like to remove the sidebar to (a new file) sidebar.php and use an include on all the other pages so that any time the sidebar changes I can change and reupload only one file rather than 100.
I know this can be done in Javascript, but I'd rather not. I'd like an option that works for *every* visitor, not simply the ones visiting in a Javascript-capable browser with Javascript turned on.
The code I was thinking of was something like
$here = $_SERVER['PHP_SELF'];
if ($here == '/index.php')
print "
Home";
else
print "
Home";
It works, and I suspect it won't be a problem even though we have just a very basic hosting package and get about 5k page views a week. (The math: 5,000 page hits a week * 10 if/thens = 50k if/thens/week = 7153 if/thens a day = 297 an hour = 5 a minute = most likely not a problem.) But how do you know how much of that kind of access a host permits? At what point does it get their attention and/or ire?
Also, how do you calculate the burden of proposed code? Where does one go for that information? What do you do to make sure you're writing code that can handle a lot of traffic?
if ($here == '/index.php')
print "<span class=\"here\">Home</span>";
else
print "<a href=\"index.php\">Home</a>";
posted by Tuwa at 10:36 PM on August 24, 2007