Forum Moderators: coopster
I'm in affiliate business. I use PHP redirects for outgoing links for two main reasons:
- tracking
- easiness of link maintenance at one place
Average PHP script is anywhere between 10 to 100 lines
All what happens inside is something like this:
- Make a call to another script that has those lines:
$v1 = $_COOKIE['var1'];
if ($v1 == "something")
{
$v2 = "something-else";
} else {
$v2 = $_COOKIE['var2'];
}// end IF
$v3 = $_COOKIE['var3'];
$s = $_GET['s'];
$final = "$v1-$v2-$v3-$s";
if ($s == "link1") {$link = "http://www.example.com";}
header("Location: $link$final");
In Webmaster Tools, Google shows my HTML files to be loading in about 1 second, while those PHP files are taking up to 8 seconds.
To add bit of irony, shared hosting processing seems to be faster than VPS with prominent hosts.
Anyway:
1. Do you think that PHP is slow by its nature?
2. From end user perspective, how do you compare the speed of PHP to other programming solutions?
3. Probably silly question, but is my code any time demanding?
All what I want is to shed away the possibility of PHP being a real cause of my sites being slow in Google's eyes.
As the "Site performance" is (I believe) in its experimental phase from ranking factor perspective, I would like to point out to this part so we get ready in early 2010.
Thanks
That said, with today's interpreters and processors you likely won't notice the difference ;)
If your PHP code is taking 8 seconds to process simple functions as this you need to address something as this just doesn't sound right. A mere 100 line script without any loops should be over in milliseconds. Are you certain it is your script and not an external call or something else?
One note regarding your "if" control structure there. Rather than:
if ($s == "link1") {$link = "http://www.example.com";} $links = array(
'link1' => 'http://www.example.com',
'link2' => 'http://www.example.net',
'link3' => 'http://www.example.org'
);
$link = isset($links[$s]) ? $links[$s] : false;
if ($link) {
header("Location: $link$final");
exit;
}
If your PHP code is taking 8 seconds
That's per Google's WMT, not in my real world. I'm just trying to determine how they develop numbers that are over 2 seconds. Among other things, I would like to see if I can change it by changing PHP code.
It may also be that Google is doing something wrong when they calculate this.
I would like to see if I can change it by changing PHP code.
Create a PHP test page with a redirect on it.
Submit it to Google.
Check the time in WMT.
You'll have your answer...
Test.php = <?php header('Location: http://www.example.com/'); ?>
Just a note... Your redirects are 302's unless you precede them with:
header('HTTP/1.1 301 Moved Permanently');
Or, some other defined redirect status.
IDK if the preceding has an effect on how they calculate things, but it's worth looking at.