From 7d48dd810362cf07147cecf77190c9808912b59f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 17 Feb 2021 15:00:32 +0100 Subject: [PATCH] Fix cache --- htdocs/theme/eldy/manifest.json.php | 11 +++++++++-- htdocs/theme/md/manifest.json.php | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/htdocs/theme/eldy/manifest.json.php b/htdocs/theme/eldy/manifest.json.php index c8f3ef3a271..7aa04694b33 100644 --- a/htdocs/theme/eldy/manifest.json.php +++ b/htdocs/theme/eldy/manifest.json.php @@ -35,6 +35,7 @@ if (!defined('NOLOGIN')) define('NOLOGIN', '1'); if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOSESSION')) define('NOSESSION', '1'); require_once __DIR__.'/../../main.inc.php'; @@ -43,8 +44,14 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli = $conf->global->MAIN_ top_httphead('text/json'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); -else header('Cache-Control: no-cache'); +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); + // For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server + header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800) . ' GMT'); +} +else { + header('Cache-Control: no-cache'); +} ?> { diff --git a/htdocs/theme/md/manifest.json.php b/htdocs/theme/md/manifest.json.php index 5f07177ed96..6051ff260ef 100644 --- a/htdocs/theme/md/manifest.json.php +++ b/htdocs/theme/md/manifest.json.php @@ -35,6 +35,7 @@ if (!defined('NOLOGIN')) define('NOLOGIN', '1'); if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOSESSION')) define('NOSESSION', '1'); require_once __DIR__.'/../../main.inc.php'; @@ -43,8 +44,14 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli = $conf->global->MAIN_ top_httphead('text/json'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); -else header('Cache-Control: no-cache'); +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); + // For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server + header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800) . ' GMT'); +} +else { + header('Cache-Control: no-cache'); +} ?> {