This is a 2 part question…
1) Does file_get_contents create server load? I am using it a solid 3+ times in my blogs sidebar to pull out advertisements through my blog network, but now the network is slowing down. I want to make sure that’s not the cause.
2) What IS the best way to handle cross-server includes? Like I said above, I am using file_get_contents, and probably doing it in a VERY poor way. Looking at some of my code, I’ll see:
<?
$c = file_get_contents("http://www.url.com/includes/include1.php");
echo ($c);
?>
<?
$c = file_get_contents("http://www.url.com/includes/include2.php");
echo ($c);
?>
I understand right now that’s sloppy because it’s opening and closing php when you don’t need to, plus it’s putting two different URL’s under the same variable. That makes me wonder how it even works at this point.
Anyway, I’m looking for the best solution to my cross-server include problem which will hopefully lower the drag on my server under heavier loads.
Thank yo!
You should not allow cross-server includes. What would be stopping someone other than you from reading the contents of your PHP files?
As for your original question: If you are concerned about responsiveness, then load your advertisements via Ajax (I recommend jQuery). That way the real content will load quickly with the ads arriving shortly afterwards.
Another option to consider would be caching your ads somehow.