php hesitates 5 seconds

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MAtkins
Forum Newbie
Posts: 17
Joined: Fri Apr 02, 2010 3:55 pm

php hesitates 5 seconds

Post by MAtkins »

Hi:

I've got a MySql database app that I decided to do in php.
I'm running it on a Windows box in IIS.

When I run it I'm noticing that it seems to hesitate for about 5 to 10 seconds.
The page & form comes up right away but then it waits before completing the page load.

My php code is mostly at the top of the page and in includes (require_once).

Is there anything I can do to find the hesitation and make the page load quickly?

Also, I've got a bit of a caching problem.
I used:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

which seems to work but this looks like overkill maybe?
What is the best way to insure that the DATA is fresh?
MAtkins
Forum Newbie
Posts: 17
Joined: Fri Apr 02, 2010 3:55 pm

Re: php hesitates 5 seconds

Post by MAtkins »

It takes SEVEN seconds to deliver this page:
I"m running Windows IIS.
Cached pages are useless in a database application.

Is there any way to speed this up?

<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php echo "Testing 1, 2, 3"?>
</body>
</html>
lunarnet76
Forum Commoner
Posts: 67
Joined: Sun Apr 04, 2010 2:07 pm
Location: Edinburgh

Re: php hesitates 5 seconds

Post by lunarnet76 »

in case it helps PHP official no-cache is

Code: Select all

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
so apparently the last modified is useless, but you have it good, so it does not come from the caching!

Are you sure your computer is powerful enough, that you are not running the web server from the network or from a usb key?^^ just asking the obvious but we never know ...
otherwise try to use php-recommended.ini with a newly installed iis ! or ban microsoft from your life :mrgreen:
MAtkins
Forum Newbie
Posts: 17
Joined: Fri Apr 02, 2010 3:55 pm

Re: php hesitates 5 seconds

Post by MAtkins »

Thanks for the reply.
I run ASP and ASP.NET applications on that server with no problem.

The page, including any data it pulls, comes up right away but something is keeping the page load from completing.
Surely someone else has experienced this.

The code in the previous post is about as simple a php page as I can dream up.
That page shouldn't take anywhere near 7 seconds to load but it does.

Can anyone please give me an idea as to what might be causing it and how to get it to stop hesitating?
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

Re: php hesitates 5 seconds

Post by Technocrat »

IF you remove all the PHP code and just have HTML does it take that long to serve it up?

How did you install php? LAMP? IIS? FastCGI?
MAtkins
Forum Newbie
Posts: 17
Joined: Fri Apr 02, 2010 3:55 pm

Re: php hesitates 5 seconds

Post by MAtkins »

Technocrat-Evo thanks for the reply.
I set up 3 pages:

http://etracker.softlinksys.com/TestHtm.htm
http://etracker.softlinksys.com/TestNoPHP.php
http://etracker.softlinksys.com/TestWithPHP.php

The html comes up as normal.
Both of the php pages hesitate.

When I first download it I hold Ctrl down to insure a fresh copy.
I tried it holding Ctrl down and not, either way it takes about 5 to 7 seconds.

It's installed on a Windows 2003 box, IIS 5
I don't remember how I installed it.
Normally I'd use a Windows installer if available.
Normally I save my installation files too but apparently didn't this time.

I don't know how dangerous this is (maybe you could inform me?) but
http://etracker.softlinksys.com/PHPInfo.php
This should tell you everything about the installation.
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

Re: php hesitates 5 seconds

Post by Technocrat »

Strange it acts like a compiler issue. Have you run PHP on this box before?

I might try to update to a 5.3 branch maybe. Perhaps its a bug with your install & windows.
MAtkins
Forum Newbie
Posts: 17
Joined: Fri Apr 02, 2010 3:55 pm

Re: php hesitates 5 seconds - Technocrat-Evo ROCKS!

Post by MAtkins »

Sorry this took so long - my multi-tasking skills are somewhat linear at times (ie not multi :)

THANK YOU Technocrat-Evo

I finally got a new install of php 5.3.2 and in the process saw an opportunity to use IIS 'FastCGI'.
It said I didn't have it so I googled it & found that it was a Microsoft installation.
I installed FastCGI into IIS 6 on my Windows Server 2003 box with very little pain.

I went back and did the install for php 5.3.2 and now my php pages are about as fast as I can expect with asp.net.
Thanks very much for your help.

I'm *really* looking forward to completely scrapping ASP.NET C# and MICROSOFT!!!
Post Reply