Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2 different php request at same time per user

I have a website which has 2 pages , (home_page.php and action_page.php)Action page takes aprx. 2 minutes to completely load (server side takes 2 minutes) . But if user clicks to home page link while action page is loading , browser does not go to home page , until action page is completely loaded. Same thing if the home page is opened in a new tab.

First of all what is the reason of this ? (bowser ? php ? apache ?) and how can I avoid this ?

Thank you

like image 202
Oguz Bilgic Avatar asked May 30 '10 13:05

Oguz Bilgic


2 Answers

More than likely, it's because a session is locked. PHP will only allow one request per session to prevent issues coming up (overwriting data, etc). See: session_write_close()...

like image 146
ircmaxell Avatar answered Nov 08 '22 06:11

ircmaxell


If the page is taking 2 minutes to load, then you are reaching the network timeout limits of a typical browser. That is a really long time for a page to load. You may want to consider spawning a separate process to do handle the long processing. You can put the result in a database, file, etc and use polling to check if it's done.

When spawning a process (exec()), make sure you use nohup, background it (&) and direct error output to /dev/null, otherwise it won't disconnect from the web process, and the web process will wait for it to finish.

like image 44
Brent Baisley Avatar answered Nov 08 '22 08:11

Brent Baisley