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("Locatio n:member.php").
I tried changing the header() command in a few ways:
header("Locatio n:/member.php"), header("Locatio n:./member.php"),
header("Locatio n:http://www.site.com/member.php"). But none of these
made any difference.
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.
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).
Monty 7 2871
On 15 Nov 2005 14:02:36 -0800, "Monty" <mo****@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("Locatio n: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/....html#sec14.30
I tried changing the header() command in a few ways: header("Locati on:/member.php"), header("Locatio n:./member.php"), header("Locati on: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 :: an**@andyh.co.u k :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
The PHP version on my server is part of the standard Red Hat Linux ES
3.0 bundle, and is updated by RedHat, so, while the version may be
4.3.2, it has all the fixes and security updates already applied by
RedHat Up2date.
None of the things you mention as a possible cause for this are
relevant, actually, because the fix is to add an "exit;" after a
header. Once I do that, it works as it used to. If the cause was
something else, I presume adding an exit would make no difference, but
it does. As I mentioned previously, I have made no other changes to
this code or PHP before this issue arose, the database table is not
large at all, and even when using a full, non-relative domain in the
header() function, it made no difference at all.
The only thing that did work was to add "exit;" after all
header("Locatio n:...") functions. I checked the online PHP manual, and
there's no mention that this is necessary, so, I am totally baffled as
to why this suddenly started happening.
On 15 Nov 2005 18:35:06 -0800, "Monty" <mo****@hotmail .com> wrote: The only thing that did work was to add "exit;" after all header("Locati on:...") functions. I checked the online PHP manual, and there's no mention that this is necessary, so, I am totally baffled as to why this suddenly started happening.
The header("Locatio n:...") function does not terminate your script.
So any processing after the header() will continue. Usually that's
not what you want -- you usually want to exit() at that point.
What does you script do after the header is sent? Chances are, it's
still doing something.
Following on from Monty's message. . . The only thing that did work was to add "exit;" after all header("Locati on:...") functions. I checked the online PHP manual, and there's no mention that this is necessary, so, I am totally baffled as to why this suddenly started happening.
Just out of curiosity. What happens if you replace exit; with
print("after header"); ? (I can't say I've ever had this prob 'cos I
always used exit anyway.)
--
PETER FOX Not the same since the bookshop idea was shelved pe******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.co.uk>
On Wed, 16 Nov 2005 10:02:04 +0000, Peter Fox
<pe******@emine nt.demon.co.uk. not.this.bit.no .html> wrote: Following on from Monty's message. . .The only thing that did work was to add "exit;" after all header("Locat ion:...") functions. I checked the online PHP manual, and there's no mention that this is necessary, so, I am totally baffled as to why this suddenly started happening. Just out of curiosity. What happens if you replace exit; with print("after header"); ? (I can't say I've ever had this prob 'cos I always used exit anyway.)
You shouldn't see anything. You'll end up transmitting "after header"
to the browser but it'll see the location header and redirect anyway.
On 15 Nov 2005 18:35:06 -0800, "Monty" <mo****@hotmail .com> wrote: The PHP version on my server is part of the standard Red Hat Linux ES 3.0 bundle, and is updated by RedHat, so, while the version may be 4.3.2, it has all the fixes and security updates already applied by RedHat Up2date.
Ah. Fair enough.
None of the things you mention as a possible cause for this are relevant, actually, because the fix is to add an "exit;" after a header. Once I do that, it works as it used to. If the cause was something else, I presume adding an exit would make no difference, but it does.
I'm suggesting that some of your code that is running after the header() call
that is taking a significant time.
Adding exit immediately after header() prevents that code running.
For a trivial example:
<?php
header("Locatio n: http://www.php.net/");
sleep(10);
?>
This takes 10 seconds to actually redirect. So the code that runs after
header() is significant. exit skips it. If it worked before, then surely it is
a possible cause that the code used to run quickly so you didn't notice, but
now it runs slowly.
So, what is running after the header call?
--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
> So, what is running after the header call?
Hi. The only code that would be executed after the header() call is to
load a record from the DB to display it in the form. That's it. When I
remove the header() call completely (allowing the page to reload), it
happens instantly, so, I don't think the code that follows is causing
the delay. But, if I put the header() call back in without an exit, it
takes hangs for minutes before moving forward.
And the odd thing is that this never happened before, and I didn't make
any changes at all to these scripts that are all of sudden hanging at a
header() call if not followed by exit. But, it's also not ALL header()
calls doing this. On some pages without an exit, it happens just as
fast as when I add the exit, so, the results seem to be very
inconsistent.
I guess no one else has been having this problem. Very strange! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ben Floyd |
last post by:
It goes like this:
Im converting a perl script that executes a command on each result of
a directory listing. In perl, all is well. In Python, using
approximately
the same logic creates a seemingly random problem I can't pin down.
I hesitated to ask this question since it's so Slackware
Linux-centric,
and im new to Python. It's hard to ask in a generic way, but im out of
options...
|
by: ghasem |
last post by:
Dear mySQL community,
I have once again turned to the user groups for a problem I cannot
solve myself! Atually, I have read all I can from the newsgroups on
this but I could not solve it myself.
Here it is:
mySQL server: version "4.0.20-standard" on localhost
hardware : 1.8 MHz Pentium 4 with 512 cache and 512 MB 266MHz RAM and
40 MB Matrox+ harddisk
Here is the problem:
|
by: MAB71 |
last post by:
I'm running an ISP database in SQL 6.5 which has a table 'calls'. When the
new month starts I create a new table with the same fields and move the data
of previous month into that table and delete it from calls. So 'calls' holds
the data of only the current month. for example at the start of november
2003 I ran the queries
Create Table Oct2003Calls {
................
................
|
by: Mike |
last post by:
I have posted this before, but no one responds, so here
it goes again. I think my question is intimidating people
and I have no idea why?!? This is not a new concept. You
can do this with other programming languages, so why is
C# so different? Again, here is my baffling C# question.
I have C# code that opens an application, but right after
it opens I am confronted by prompts for information
(i.e. "Please enter your id"). I would like to...
|
by: Amelyan |
last post by:
It takes VS 2005 1, 2, and somtimes 3 MINUTES to compile ASP.NET 2.0 website
when external DLL is modified. As a matter of fact, when I click 'Build',
it looks like VS 2005 hangs for most of that time before it actually starts
compiling. If I modify something inside WebSite project itself without
modifying DLL, it takes few seconds to compile.
Why? How can I control this behavior?
I was able to reproduce this behavior by creating a...
| |
by: hazz |
last post by:
What happens if I set the timer interval for a period that is less than the
time it will take to process the loop below? Right now my application is
returning just a few items in an arraylist to process but the process should
scale to 100 or even 1000 loops. If the functions contained within the loop,
some of which go out to web services, take an indeterminate amount of time,
how do I design my windows service so that if the code takes...
|
by: Rick Sypriano |
last post by:
Hello,
I have a WebService that uses ADO.net to update a SQL database on a
remote server. If the database operation takes less than 4 minutes
everything works fine. If the database operation takes more than 5
minutes or so the service does not return to the client. The client
hangs waiting for a response that never comes.
I have written to a log file when the database operation finishes; so I
know when the service should return. I...
|
by: Martin Eckart |
last post by:
Hello,
I have built a Hello World Web Service using Visual Studio 2005 and .NET 2.0
on machine A. Setting up a Web Site on machine B and adding a web reference
to that WS works fine, without any delays.
Setting up the same Web Site on machine C it takes forever after I select
the WS and hit the "Add Reference" button in the wizard. Every time I
updated the web reference the same. In addition the executing of the
application takes...
|
by: DR |
last post by:
PerformanceCounterCategory.Create() takes 3 minutes to add a new category!!
If I run PerformanceCounterCategory.Create() on my development machine it
only takes a
few seconds. But on remotely monitored machines it takes 3 minutes! Is this
because the
other machines are remotely monitored? Something else?
What all can make PerformanceCounterCategory.Create() take 3 minutes to add
a new category??
|
by: jr |
last post by:
I have an application the makes a call to a webservice to retrieve some
additional info for my app. The information I get back is
non-essential, so I do NOT want my entire app hanging to wait for this
repsonse if it takes more than, say, 2 seconds to a response from the
webserver.
Basically, how would I immediately end a function that is taking too
long to respond?
--
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |