Add cache headers to cron endpoints
[MAILPOET-1464]
This commit is contained in:
committed by
pavel-mailpoet
parent
c7aeca116f
commit
659f748dc9
@ -25,6 +25,7 @@ class Daemon {
|
||||
}
|
||||
|
||||
function ping() {
|
||||
$this->addCacheHeaders();
|
||||
$this->terminateRequest(self::PING_SUCCESS_RESPONSE);
|
||||
}
|
||||
|
||||
@ -33,6 +34,7 @@ class Daemon {
|
||||
if(strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
|
||||
set_time_limit(0);
|
||||
}
|
||||
$this->addCacheHeaders();
|
||||
if(!$this->request_data) {
|
||||
$error = __('Invalid or missing request data.', 'mailpoet');
|
||||
} else {
|
||||
@ -135,4 +137,16 @@ class Daemon {
|
||||
$daemon['token'] !== $this->token ||
|
||||
(isset($daemon['status']) && $daemon['status'] !== CronHelper::DAEMON_STATUS_ACTIVE);
|
||||
}
|
||||
|
||||
private function addCacheHeaders() {
|
||||
if(headers_sent()) {
|
||||
return;
|
||||
}
|
||||
// Common Cache Control header. Should be respected by cache proxies and CDNs.
|
||||
header('Cache-Control: no-cache');
|
||||
// Mark as blacklisted for SG Optimizer for sites hosted on SiteGround.
|
||||
header('X-Cache-Enabled: False');
|
||||
// Set caching header for LiteSpeed server.
|
||||
header('X-LiteSpeed-Cache-Control: no-cache');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user