What happens when a user sends an asynchronous request to a server to update its database that may take a couple minutes, but then leaves the webpage before the update is done?
Will the server still record the update to the database or stop?
I'm using angularjs to make async calls to a LAMP stack.
Assuming that:
Then no, the server will not record the update to the database.
As @AD7six pointed out and according to this php manual reference:
Why:
The default behaviour is however for your script to be aborted when the remote client disconnects.
If you do not tell PHP to ignore a user abort and the user aborts, your script will terminate.
Options:
You can decide whether or not you want a client disconnect to cause your script to be aborted. Sometimes it is handy to always have your scripts run to completion even if there is no remote browser receiving the output.
How:
This behaviour can be set via the ignore_user_abort php.ini directive as well as through the corresponding php_value ignore_user_abort Apache httpd.conf directive or with the ignore_user_abort() function.
There is a TIMEOUT
abort as well:
Why:
Your script can also be terminated by the built-in script timer. The default timeout is 30 seconds.
If you do not tell PHP to ignore a user abort and the user aborts, your script will terminate.
Options:
It can be changed using the max_execution_time php.ini directive or the corresponding php_value max_execution_time Apache httpd.conf directive as well as with the set_time_limit() function.
This is the basic client-server communication flow:
The client (the webpage, browser..) send a request (sync/async) to a server and
the server responds with a reponse to the client.
The server can handle connection timeouts and abort as well as the client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With