From 1ff92618f22b92683ca85bff30f368f76d86d9c5 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 5 Jul 2022 03:12:36 +0000 Subject: [PATCH] Cron API: Make wp-cron non-blocking for LiteSpeed LSAPI. This should make cron spawning faster on LSAPI by ensuring that cron requests return immediately. To avoid code repetition, the no caching headers are relocated and always sent. Caching plugins attempting to set these headers later will replace those set by WordPress Core. Follow up to [44488]. Props maximej, johnbillion. Fixes #54668. git-svn-id: https://develop.svn.wordpress.org/trunk@53653 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-cron.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/wp-cron.php b/src/wp-cron.php index 32f8d3ead6..ceaf5d1e65 100644 --- a/src/wp-cron.php +++ b/src/wp-cron.php @@ -18,14 +18,16 @@ ignore_user_abort( true ); +if ( ! headers_sent() ) { + header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); + header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); +} + /* Don't make the request block till we finish, if possible. */ if ( PHP_VERSION_ID >= 70016 && function_exists( 'fastcgi_finish_request' ) ) { - if ( ! headers_sent() ) { - header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); - header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); - } - fastcgi_finish_request(); +} elseif ( function_exists( 'litespeed_finish_request' ) ) { + litespeed_finish_request(); } if ( ! empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) {