From 8683e4bd9aa43cac69d3c1a68e0103dd1946d739 Mon Sep 17 00:00:00 2001 From: andryyy Date: Tue, 29 Oct 2019 14:21:58 +0100 Subject: [PATCH] [Rspamd] Use last-modified headers to not read unmodified settings map every 30 seconds --- data/conf/rspamd/dynmaps/settings.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/data/conf/rspamd/dynmaps/settings.php b/data/conf/rspamd/dynmaps/settings.php index 705682b4..acac7221 100644 --- a/data/conf/rspamd/dynmaps/settings.php +++ b/data/conf/rspamd/dynmaps/settings.php @@ -7,8 +7,6 @@ then any of these will trigger the rule. If a rule is triggered then no more rul header('Content-Type: text/plain'); require_once "vars.inc.php"; // Getting headers sent by the client. -//$headers = apache_request_headers(); - ini_set('error_reporting', 0); //$dsn = $database_type . ':host=' . $database_host . ';dbname=' . $database_name; @@ -28,21 +26,22 @@ catch (PDOException $e) { } // Check if db changed and return header -/*$stmt = $pdo->prepare("SELECT UNIX_TIMESTAMP(UPDATE_TIME) AS `db_update_time` FROM information_schema.tables +$stmt = $pdo->prepare("SELECT UNIX_TIMESTAMP(UPDATE_TIME) AS `db_update_time` FROM information_schema.tables WHERE `TABLE_NAME` = 'filterconf' AND TABLE_SCHEMA = :dbname;"); $stmt->execute(array( ':dbname' => $database_name )); $db_update_time = $stmt->fetch(PDO::FETCH_ASSOC)['db_update_time']; - -if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == $db_update_time)) { +if (empty($db_update_time)) { + $db_update_time = 1572048000; +} +if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $db_update_time)) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', $db_update_time).' GMT', true, 304); exit; } else { header('Last-Modified: '.gmdate('D, d M Y H:i:s', $db_update_time).' GMT', true, 200); } -*/ function parse_email($email) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) return false;