Reply to Re: Baffling! Redirects with header() takes minutes to respond.

Your name:

Reply:


Posted by Andy Hassall on 11/16/05 00:14

On 15 Nov 2005 14:02:36 -0800, "Monty" <monty3@hotmail.com> wrote:

>Something odd is happening. Scripts on several sites that collect form
>data, save it to a DB, then redirect the user to another page are
>slowing to a crawl during the redirect using the header() function. For
>example: header("Location:member.php").

The HTTP standards prohibit relative URIs in the Location header, so you're
relying on whatever the browser does to compensate for invalid headers.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30

>I tried changing the header() command in a few ways:
>header("Location:/member.php"), header("Location:./member.php"),
>header("Location:http://www.site.com/member.php"). But none of these
>made any difference.

The final one is at least valid.

>I then discovered that if I put "exit;" after the header() function,
>there's no more delay and the redirect is instantaneous again.
>
>What's odd is that these pages worked just fine without the exit
>command until recently. I've made no changes to those scripts, or to
>PHP, so, I can't figure out why this all of a sudden started happening.
>
>Has anyone else noticed this? Is putting an "exit;" right after a
>header() now required in PHP? Because I never had to do this before and
>it always worked fine.

It's never been required, but for Location it makes sense; there's not a great
deal of point outputting more content after it.

What code actually runs after the header? Odds are something has changed
there. You mention a database; has a table got considerably larger over time,
resulting in a previously fast query turning into a long-running query running
after the header() call?

>Using PHP 4.3.2 on Linux Red Hat ES 3.0 server. Tested this in Safari,
>Firefox and MS IE, with the same (slow) redirect results (until "exit;"
>was added).

4.3.2 is rather old - 4.3.11 is the latest on that branch, or 4.4.1 for the
latest PHP4. Probably not immediately relevant, but there are a lot of nasty
bugs if you're that far behind, including security issues.
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация