Current Option
If I have a process that I know may take a while I have been chopping it up using ajax to do a part of the request then once the ajax is returned do the next part of the request.
This is helpful because I can track percentage complete after each ajax returns but it relies on the browser sending the ajax requests, which may still timeout.
New Option Theory
I think a better way is to let the server side code keep running the task without coming back to report to the GUI.
On the server side I have the script just run all tasks. It tracks its own run time and before max_execution_time is hit it spawns and another task (via cURL) and exits.
On the client side I run an interval every second or so checking the progress (minimal ajax script).
This would prevent the script from halting if the browser were to reload.
To get the theory to work I have to answer the following questions:
-
How can you check if the max execution time is near?
-
Is there a better way to accomplish this then cURL?
-
Can you even create a cURL request and end the script without waiting for the response or canceling the cURL?
The real question here is:
- How can you run a “process” that will run longer that the max execution time without changing max execution time?
1