Do not cache http responses on "ok" or "error" JSON responses

This commit is contained in:
Bofh 2022-12-17 22:27:45 +01:00
parent f89fde5c66
commit 01dbd06e8e
1 changed files with 5 additions and 1 deletions

View File

@ -57,9 +57,13 @@ function apiresult($data, $code=200) {
header('Content-Type: application/json'); 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'], content_cache__put($GLOBALS['http_cache_config']['key'],
'ondemand,'.$GLOBALS['http_cache_config']['seconds'], $data); 'ondemand,'.$GLOBALS['http_cache_config']['seconds'], $data);
if (gettype($data) !== 'string') if (gettype($data) !== 'string')
echo json_encode($data); echo json_encode($data);
else echo $data; else echo $data;