1

I read that wp-cron runs when a page load request comes. So, if PHP is single threaded how can all the cron jobs run as a separate task?

If that's not the case, may anyone please help to understand the implementation that runs the cron job and also sends the response without making the client wait for cron job to finish?

  • 1
    the cron laucher send a asynchronous HTTP request and continue the page loading. then the page loading is not decelerated and the cron job run in background on another PHP thread. look this : wordpress.stackexchange.com/questions/125995/… – mmm Feb 11 '18 at 11:42
  • So is there two requests(one synchronous that is for page load & another asynchronous that you mentioned) on every page load? How is this cron launcher triggered? Is it triggered after processing page load request or before that? – learning_13 Feb 11 '18 at 11:46
  • 2
    the function wp_cron which launches the HTTP request is hooked at the action init. – mmm Feb 11 '18 at 11:57
  • 2
    there is no such thing. one task -> lock -> task done -> lock release -> check for next job. – Butuzov Feb 11 '18 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.