How are long jobs handled, e.g. Contact import
It depends on the job.

Import jobs (Contacts, Contributions...) work by having one long-running POST request, and then your browser polls for updates on progress.

This means your browser/server/interenet connection need to be able to cope with the time that POST request requires. Whether a job completes after apparently timing out depends on how PHP is set up on your site.

For example:


Using Apache + mod_php: I believe that if the script times out on the POST request, processing stops at the point it got to.
Using nginx + PHP FPM: nginx will give up and issue a Gateway Timeout according to its configuration, but the PHP process may still carry on regardless, until completion.


So for import jobs, it's best to configure your server's timeouts to exceed the time taken for the biggest import you're likely to need to do, and/or break your imports down into smaller chunks that can be handled within those timeouts

Other jobs (dedupe merge, and applying database upgrades are examples) may use CiviCRM's queue system. This has two ways to get processed.


A server-side CLI script may chug through the entire queue without any timeouts.
A browser-side process with a progress bar works differently and requires the browser to process each step of the queue. If a single step ("task") takes longer than the configured timeouts, you're in trouble. If you close your browser, the next step won't run and the last step may (or may not) fail. If you close your browser and re-open it, you may start running the tasks more than once, in parallel (so don't do this!).


See my newly added Queue Reference in the developer docs.