Resolve #891 and other index cache issues

This commit is contained in:
the-djmaze 2023-02-03 09:20:42 +01:00
parent 11c5b0e8f1
commit 16daa7b55e
5 changed files with 27 additions and 21 deletions

View file

@ -257,6 +257,8 @@ http_expires = 3600
; Caching message UIDs when searching and sorting (threading) ; Caching message UIDs when searching and sorting (threading)
server_uids = On server_uids = On
system_data = On
[imap] [imap]
use_force_selection = Off use_force_selection = Off
use_expunge_all_on_delete = Off use_expunge_all_on_delete = Off
@ -266,7 +268,6 @@ message_all_headers = Off
show_login_alert = On show_login_alert = On
[labs] [labs]
cache_system_data = On
date_from_headers = On date_from_headers = On
allow_message_append = Off allow_message_append = Off
login_fault_delay = 1 login_fault_delay = 1

View file

@ -29,7 +29,7 @@
**Editing HTML Template Files** **Editing HTML Template Files**
1. Edit data/\_data_/\_default_/configs/application.ini 1. Edit data/\_data_/\_default_/configs/application.ini
2. Set 'cache_system_data' to Off 2. Set `[cache] system_data` to Off
**Release** **Release**

View file

@ -93,15 +93,19 @@ class Application extends \RainLoop\Config\AbstractConfig
{ {
// Workarounds for the changed application structure // Workarounds for the changed application structure
if ('labs' === $sSectionKey) { if ('labs' === $sSectionKey) {
if (\str_contains($sParamKey, 'imap_')) { if (\str_starts_with($sParamKey, 'imap_')) {
$sSectionKey = 'imap'; $sSectionKey = 'imap';
$sParamKey = \str_replace('imap_', '', $sParamKey); $sParamKey = \str_replace('imap_', '', $sParamKey);
} }
if (\str_contains($sParamKey, 'use_app_debug_')) { if (\str_starts_with($sParamKey, 'use_app_debug_')) {
$sSectionKey = 'debug'; $sSectionKey = 'debug';
$sParamKey = \str_replace('use_app_debug_js', 'javascript', $sParamKey); $sParamKey = \str_replace('use_app_debug_js', 'javascript', $sParamKey);
$sParamKey = \str_replace('use_app_debug_css', 'css', $sParamKey); $sParamKey = \str_replace('use_app_debug_css', 'css', $sParamKey);
} }
if ('cache_system_data' === $sParamKey) {
$sSectionKey = 'cache';
$sParamKey = 'system_data';
}
} }
parent::Set($sSectionKey, $sParamKey, $mParamValue); parent::Set($sSectionKey, $sParamKey, $mParamValue);
} }
@ -363,7 +367,9 @@ Enables caching in the system'),
'http' => array(true, 'Browser-level cache. If enabled, caching is maintainted without using files'), 'http' => array(true, 'Browser-level cache. If enabled, caching is maintainted without using files'),
'http_expires' => array(3600, 'Browser-level cache time (seconds, Expires header)'), 'http_expires' => array(3600, 'Browser-level cache time (seconds, Expires header)'),
'server_uids' => array(true, 'Caching message UIDs when searching and sorting (threading)') 'server_uids' => array(true, 'Caching message UIDs when searching and sorting (threading)'),
'system_data' => array(true)
), ),
'imap' => array( 'imap' => array(
@ -376,7 +382,6 @@ Enables caching in the system'),
), ),
'labs' => array( 'labs' => array(
'cache_system_data' => array(true),
'date_from_headers' => array(true, 'Display message RFC 2822 date and time header, instead of the arrival internal date.'), 'date_from_headers' => array(true, 'Display message RFC 2822 date and time header, instead of the arrival internal date.'),
'allow_message_append' => array(false), 'allow_message_append' => array(false),
'login_fault_delay' => array(1), 'login_fault_delay' => array(1),

View file

@ -150,25 +150,21 @@ abstract class Service
$oActions = Api::Actions(); $oActions = Api::Actions();
$sThemeName = $oActions->GetTheme($bAdmin);
$aTemplateParameters = array( $aTemplateParameters = array(
'{{BaseAppThemeName}}' => $sThemeName,
'{{BaseAppFaviconPngLinkTag}}' => $sFaviconPngLink ? '<link type="image/png" rel="shortcut icon" href="'.$sFaviconPngLink.'">' : '', '{{BaseAppFaviconPngLinkTag}}' => $sFaviconPngLink ? '<link type="image/png" rel="shortcut icon" href="'.$sFaviconPngLink.'">' : '',
'{{BaseAppFaviconTouchLinkTag}}' => $sAppleTouchLink ? '<link type="image/png" rel="apple-touch-icon" href="'.$sAppleTouchLink.'">' : '', '{{BaseAppFaviconTouchLinkTag}}' => $sAppleTouchLink ? '<link type="image/png" rel="apple-touch-icon" href="'.$sAppleTouchLink.'">' : '',
'{{BaseAppMainCssLink}}' => Utils::WebStaticPath('css/'.($bAdmin ? 'admin' : 'app').$sAppCssMin.'.css'),
'{{BaseAppManifestLink}}' => Utils::WebStaticPath('manifest.json'), '{{BaseAppManifestLink}}' => Utils::WebStaticPath('manifest.json'),
'{{BaseFavIconSvg}}' => $sFaviconUrl ? '' : Utils::WebStaticPath('favicon.svg'), '{{BaseFavIconSvg}}' => $sFaviconUrl ? '' : Utils::WebStaticPath('favicon.svg'),
'{{LoadingDescriptionEsc}}' => \htmlspecialchars($oConfig->Get('webmail', 'loading_description', 'SnappyMail'), ENT_QUOTES|ENT_IGNORE, 'UTF-8'), '{{LoadingDescriptionEsc}}' => \htmlspecialchars($oConfig->Get('webmail', 'loading_description', 'SnappyMail'), ENT_QUOTES|ENT_IGNORE, 'UTF-8'),
'{{BaseAppAdmin}}' => $bAdmin ? 1 : 0, '{{BaseAppAdmin}}' => $bAdmin ? 1 : 0
'{{NO_SCRIPT_DESC}}' => \nl2br($oActions->StaticI18N('NO_SCRIPT_TITLE') . "\n" . $oActions->StaticI18N('NO_SCRIPT_DESC')),
'{{NO_COOKIE_TITLE}}' => $oActions->StaticI18N('NO_COOKIE_TITLE'),
'{{NO_COOKIE_DESC}}' => $oActions->StaticI18N('NO_COOKIE_DESC'),
'{{BAD_BROWSER_TITLE}}' => $oActions->StaticI18N('BAD_BROWSER_TITLE'),
'{{BAD_BROWSER_DESC}}' => \nl2br($oActions->StaticI18N('BAD_BROWSER_DESC'))
); );
$sCacheFileName = ''; $sCacheFileName = '';
if ($oConfig->Get('labs', 'cache_system_data', true)) { if ($oConfig->Get('cache', 'system_data', true)) {
$sCacheFileName = 'TMPL:' . $sLanguage . \md5( $sCacheFileName = 'TMPL:' . $sLanguage . \sha1(
Utils::jsonEncode(array( Utils::jsonEncode(array(
$oConfig->Get('cache', 'index', ''), $oConfig->Get('cache', 'index', ''),
$oActions->Plugins()->Hash(), $oActions->Plugins()->Hash(),
@ -184,13 +180,17 @@ abstract class Service
if ($sResult) { if ($sResult) {
$sResult .= '<!--cached-->'; $sResult .= '<!--cached-->';
} else { } else {
$sThemeName = $oActions->GetTheme($bAdmin);
$aTemplateParameters['{{BaseAppBootCss}}'] = \file_get_contents(APP_VERSION_ROOT_PATH.'static/css/boot'.$sAppCssMin.'.css'); $aTemplateParameters['{{BaseAppBootCss}}'] = \file_get_contents(APP_VERSION_ROOT_PATH.'static/css/boot'.$sAppCssMin.'.css');
$aTemplateParameters['{{BaseAppBootScript}}'] = \file_get_contents(APP_VERSION_ROOT_PATH.'static/js'.($sAppJsMin ? '/min' : '').'/boot'.$sAppJsMin.'.js'); $aTemplateParameters['{{BaseAppBootScript}}'] = \file_get_contents(APP_VERSION_ROOT_PATH.'static/js'.($sAppJsMin ? '/min' : '').'/boot'.$sAppJsMin.'.js');
$aTemplateParameters['{{BaseAppThemeName}}'] = $sThemeName; $aTemplateParameters['{{BaseAppMainCssLink}}'] = Utils::WebStaticPath('css/'.($bAdmin ? 'admin' : 'app').$sAppCssMin.'.css');
$aTemplateParameters['{{BaseAppThemeCss}}'] = \preg_replace('/\\s*([:;{},]+)\\s*/s', '$1', $oActions->compileCss($sThemeName, $bAdmin)); $aTemplateParameters['{{BaseAppThemeCss}}'] = \preg_replace('/\\s*([:;{},]+)\\s*/s', '$1', $oActions->compileCss($sThemeName, $bAdmin));
$aTemplateParameters['{{BaseLanguage}}'] = $oActions->compileLanguage($sLanguage, $bAdmin); $aTemplateParameters['{{BaseLanguage}}'] = $oActions->compileLanguage($sLanguage, $bAdmin);
$aTemplateParameters['{{BaseTemplates}}'] = Utils::ClearHtmlOutput($oServiceActions->compileTemplates($bAdmin)); $aTemplateParameters['{{BaseTemplates}}'] = Utils::ClearHtmlOutput($oServiceActions->compileTemplates($bAdmin));
$aTemplateParameters['{{NO_SCRIPT_DESC}}'] = \nl2br($oActions->StaticI18N('NO_SCRIPT_TITLE') . "\n" . $oActions->StaticI18N('NO_SCRIPT_DESC'));
$aTemplateParameters['{{NO_COOKIE_TITLE}}'] = $oActions->StaticI18N('NO_COOKIE_TITLE');
$aTemplateParameters['{{NO_COOKIE_DESC}}'] = $oActions->StaticI18N('NO_COOKIE_DESC');
$aTemplateParameters['{{BAD_BROWSER_TITLE}}'] = $oActions->StaticI18N('BAD_BROWSER_TITLE');
$aTemplateParameters['{{BAD_BROWSER_DESC}}'] = \nl2br($oActions->StaticI18N('BAD_BROWSER_DESC'));
$sResult = Utils::ClearHtmlOutput(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Index.html')); $sResult = Utils::ClearHtmlOutput(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Index.html'));
$sResult = \strtr($sResult, $aTemplateParameters); $sResult = \strtr($sResult, $aTemplateParameters);
if ($sCacheFileName) { if ($sCacheFileName) {

View file

@ -422,7 +422,7 @@ class ServiceActions
$bAdmin = 'Admin' === (isset($this->aPaths[2]) ? (string) $this->aPaths[2] : 'App'); $bAdmin = 'Admin' === (isset($this->aPaths[2]) ? (string) $this->aPaths[2] : 'App');
$sLanguage = $this->oActions->ValidateLanguage($this->aPaths[3], '', $bAdmin); $sLanguage = $this->oActions->ValidateLanguage($this->aPaths[3], '', $bAdmin);
$bCacheEnabled = $this->Config()->Get('labs', 'cache_system_data', true); $bCacheEnabled = $this->Config()->Get('cache', 'system_data', true);
if (!empty($sLanguage) && $bCacheEnabled) { if (!empty($sLanguage) && $bCacheEnabled) {
$this->oActions->verifyCacheByKey($this->sQuery); $this->oActions->verifyCacheByKey($this->sQuery);
} }
@ -460,7 +460,7 @@ class ServiceActions
$bAppDebug = $this->Config()->Get('debug', 'enable', false); $bAppDebug = $this->Config()->Get('debug', 'enable', false);
$sMinify = ($bAppDebug || $this->Config()->Get('debug', 'javascript', false)) ? '' : 'min'; $sMinify = ($bAppDebug || $this->Config()->Get('debug', 'javascript', false)) ? '' : 'min';
$bCacheEnabled = !$bAppDebug && $this->Config()->Get('labs', 'cache_system_data', true); $bCacheEnabled = !$bAppDebug && $this->Config()->Get('cache', 'system_data', true);
if ($bCacheEnabled) { if ($bCacheEnabled) {
$this->oActions->verifyCacheByKey($this->sQuery . $sMinify); $this->oActions->verifyCacheByKey($this->sQuery . $sMinify);
} }
@ -504,7 +504,7 @@ class ServiceActions
$bAppDebug = $this->Config()->Get('debug', 'enable', false); $bAppDebug = $this->Config()->Get('debug', 'enable', false);
$sMinify = ($bAppDebug || $this->Config()->Get('debug', 'css', false)) ? '' : 'min'; $sMinify = ($bAppDebug || $this->Config()->Get('debug', 'css', false)) ? '' : 'min';
$bCacheEnabled = !$bAppDebug && $this->Config()->Get('labs', 'cache_system_data', true); $bCacheEnabled = !$bAppDebug && $this->Config()->Get('cache', 'system_data', true);
if ($bCacheEnabled) { if ($bCacheEnabled) {
$this->oActions->verifyCacheByKey($this->sQuery . $sMinify); $this->oActions->verifyCacheByKey($this->sQuery . $sMinify);
} }