Jump to content

How to send a redirect header and not wait for the script to finish?


Trekx

Recommended Posts

Is it possible to force a header( "Location: $url" ) command to take effect immediately, without waiting for the script to finish?

 

I'm doing some database work after sending the redirect, and the browser is waiting for the database. Bad times.

 

 

I don't think I'm explaining it well. I might be wrong (I'm not that experienced with PHP) but the redirect seems to be much faster with the database code disabled.

 

What I'd like to happen is:

 

1) PHP sends the redirect

2) The browser goes to the new location

3) The script does the slow database work, but the visitor doesn't care

 

What seems to be happening is:

 

1) PHP sends the redirect

2) The script does the slow database work

3) The browser waits

4) The browser eventually goes to the new location, and the visitor is frustrated by the delay

 

(But maybe the header does redirect immediately. This timing problem is intermittent and hard to replicate.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.