From 01dbd06e8e8a9fda1a5104d8503f320af385f408 Mon Sep 17 00:00:00 2001 From: Bofh Date: Sat, 17 Dec 2022 22:27:45 +0100 Subject: [PATCH] Do not cache http responses on "ok" or "error" JSON responses --- base.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base.php b/base.php index 8648b55..1d6a72f 100644 --- a/base.php +++ b/base.php @@ -57,9 +57,13 @@ function apiresult($data, $code=200) { header('Content-Type: application/json'); } - if (isset($GLOBALS['http_cache_config'])) + if (isset($GLOBALS['http_cache_config']) + && gettype($data) !== 'string' + && !isset($data['error']) + && !isset($data['ok'])) content_cache__put($GLOBALS['http_cache_config']['key'], 'ondemand,'.$GLOBALS['http_cache_config']['seconds'], $data); + if (gettype($data) !== 'string') echo json_encode($data); else echo $data;