[Phpwm] PHP Website load times in Firefox

Andy Cowan andy at w4.co.uk
Fri Oct 2 12:24:38 UTC 2009


Thanks to persistent connections (again!) it really makes no difference. 
The first time PHP connects it actually connects to the database, the 
when you close the connection, PHP ignore you and keeps it open in a 
pool for reuse. Assuming you connect again with the same parameters, PHP 
just reuses the already open connection, saving you the time taken to do 
a connect and select_db.

You can turn this off (via php.ini) but there's rarely a good reason to.

So, its up to you how you do it for the sake of readability and 
maintainability. Do whatever feels better - having the connection 
explicitly obvious everytime it's used (which, to my mind is a pain in 
the arse to write every time) or open it once in an require file (which 
is much less effort). Performance-wise it'll make no difference.

Cheers

A.




On 02/10/2009 12:53, Mike Tipping wrote:
> As general practice do other people do a DB connection and select at the
> start of the app or as and when required?
>
> Cheers
>
> Mike
>
>
> On 2/10/09 12:25, "Lester Caine"<lester at lsces.co.uk>  wrote:
>
>    
>> Mike Tipping wrote:
>>      
>>> AND it always takes exactly 2 minutes (OK 1 minute 60 seconds according to
>>> net) on my computer. It looks like the MYSQL server has taken a dislike to
>>> my IP address and is purposely delaying the connection?
>>>
>>> Any ideas or advice.
>>>        
>> Use the IP address in the connection string ...
>> That will bypass any DNS lookup and so eliminate that time from the
>> equation.
>> Adding that information manually to your hosts file USED to be the quick
>> fix, but I have doubts currently.
>>      
>
>
> _______________________________________________
> Phpwm mailing list
> Website : http://www.phpwm.org
> Twitter : http://www.twitter.com/phpwm
> Facebook: http://www.facebook.com/group.php?gid=2361609907
>
> Post to list: Phpwm at mailman.lug.org.uk
> Archive etc : https://mailman.lug.org.uk/mailman/listinfo/phpwm
>    





More information about the Phpwm mailing list