php - header Location very slow

This is a discussion on php - header Location very slow within the Linux Web Servers forums, part of the Web Server and Related Forums category; Hi guys - I have a problem after a client clicks a Confirm button on a form - the form processes the ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-30-2006
One
 
Posts: n/a
Default php - header Location very slow

Hi guys - I have a problem after a client clicks a Confirm button on a
form - the form processes the data, inserts into a database, and then
redirects using header Location.

I have tested this on two different Linux/Apache servers. One works
perfectly, the other takes about 90 seconds to redirect.

Has anyone seen this issue before ?

It uses a function like this :

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCE SS, '1', 'SSL'));


function tep_redirect($url) {
if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We
are loading an SSL page
if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { //
NONSSL url
$url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); //
Change it to SSL
}
}

header('Location: ' . $url);

tep_exit();
}


In my tests - I'll receive the confirmation email *beofre* I see the
success page in the browser!

As I say - I know the function eventually _works_ - but it was
interesting to see it work properly on the other server.

THANKS!

  #2 (permalink)  
Old 12-30-2006
J.O. Aho
 
Posts: n/a
Default Re: php - header Location very slow

One wrote:
> Hi guys - I have a problem after a client clicks a Confirm button on a
> form - the form processes the data, inserts into a database, and then
> redirects using header Location.
>
> I have tested this on two different Linux/Apache servers. One works
> perfectly, the other takes about 90 seconds to redirect.


I suggest you use a small function that writes to a log file a small text
message and the time stamp, set this before everything you are going to do,
this way you see where the slowness comes from, can be that the second servers
connection to the database is so bad it takes it a lot longer to send the data
to the database which makes a delay before it come to the line where it does
the redirect.


--

//Aho
  #3 (permalink)  
Old 12-31-2006
Syl
 
Posts: n/a
Default Re: php - header Location very slow


J.O. Aho wrote:
> One wrote:
> > Hi guys - I have a problem after a client clicks a Confirm button on a
> > form - the form processes the data, inserts into a database, and then
> > redirects using header Location.
> >
> > I have tested this on two different Linux/Apache servers. One works
> > perfectly, the other takes about 90 seconds to redirect.

>
> I suggest you use a small function that writes to a log file a small text
> message and the time stamp, set this before everything you are going to do,
> this way you see where the slowness comes from, can be that the second servers
> connection to the database is so bad it takes it a lot longer to send the data
> to the database which makes a delay before it come to the line where it does
> the redirect.
>
>


Hi Aho - thanks for the reply.
Actually - the database content gets inserted successfully, and then
the confirmation email goes and successfully - and then the redirect.

I know it is the redirect because I query the db and the content is
there, and I also recieve the email - all beofre I see the success page!

  #4 (permalink)  
Old 12-31-2006
Jim Carlock
 
Posts: n/a
Default Re: php - header Location very slow

"Syl" <david.hunter@gmail.com> wrote:
: Actually - the database content gets inserted successfully, and
: then the confirmation email goes successfully - and then the
: redirect.
: I know it is the redirect because I query the db and the content
: is there, and I also recieve the email - all beofre I see the success
: page!

Are you sending any output before the headers get sent?

Perhaps there's some HTML code at the top of the page before
your PHP code starts executing? The header("Location: zzz...");
is not supposed to have any output at all before it's execution.
Then make sure there's an exit(); function right after the header();
function to make sure the script stops getting executed.

Hope this helps.

--
Jim Carlock
Post replies to the group.


  #5 (permalink)  
Old 12-31-2006
One
 
Posts: n/a
Default Re: php - header Location very slow


Jim Carlock wrote:
> "Syl" <david.hunter@gmail.com> wrote:
> : Actually - the database content gets inserted successfully, and
> : then the confirmation email goes successfully - and then the
> : redirect.
> : I know it is the redirect because I query the db and the content
> : is there, and I also recieve the email - all beofre I see the success
> : page!
>
> Are you sending any output before the headers get sent?
>
> Perhaps there's some HTML code at the top of the page before
> your PHP code starts executing? The header("Location: zzz...");
> is not supposed to have any output at all before it's execution.
> Then make sure there's an exit(); function right after the header();
> function to make sure the script stops getting executed.
>
> Hope this helps.
>



{ sigh }

THANK YOU for taking the time to post. Turns out it is a database
select issue.

I've re-posted ....... same problem, but differnet question! :-)


> Jim Carlock
> Post replies to the group.


  #6 (permalink)  
Old 12-31-2006
J.O. Aho
 
Posts: n/a
Default Re: php - header Location very slow

Syl wrote:
> J.O. Aho wrote:
>> One wrote:
>>> Hi guys - I have a problem after a client clicks a Confirm button on a
>>> form - the form processes the data, inserts into a database, and then
>>> redirects using header Location.
>>>
>>> I have tested this on two different Linux/Apache servers. One works
>>> perfectly, the other takes about 90 seconds to redirect.

>> I suggest you use a small function that writes to a log file a small text
>> message and the time stamp, set this before everything you are going to do,
>> this way you see where the slowness comes from, can be that the second servers
>> connection to the database is so bad it takes it a lot longer to send the data
>> to the database which makes a delay before it come to the line where it does
>> the redirect.
>>
>>

>
> Hi Aho - thanks for the reply.
> Actually - the database content gets inserted successfully, and then
> the confirmation email goes and successfully - and then the redirect.


I wasn't questioning that the data wasn't inserted into the database, but that
the connection to the database is slow. If there had been trouble with
inserting into the database, it had been more likely you got some error
message displayed on the web page without redirection.


> I know it is the redirect because I query the db and the content is
> there, and I also recieve the email - all beofre I see the success page!


If you are using header("Location: http://example.net"), and it takes time
before you get redirected, then the fault is before the header statement, as
this redirection don't allow delay (it's possible to make redirection with
delay, but then you need to set the delay in seconds and would affect the
script in both servers).

In your reply to Jim you say it's a select statement that causes the problem,
then you may better ask your question at alt.php.sql than a general php
newsgroup or a Unix newsgroup, where they may not be that interested in
answering when it comes to irrelevant things like php and Linux.

--

//Aho
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:07 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0