mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-25 08:08:48 +08:00
Resolve #891 and other index cache issues
This commit is contained in:
parent
11c5b0e8f1
commit
16daa7b55e
5 changed files with 27 additions and 21 deletions
|
@ -257,6 +257,8 @@ http_expires = 3600
|
|||
; Caching message UIDs when searching and sorting (threading)
|
||||
server_uids = On
|
||||
|
||||
system_data = On
|
||||
|
||||
[imap]
|
||||
use_force_selection = Off
|
||||
use_expunge_all_on_delete = Off
|
||||
|
@ -266,7 +268,6 @@ message_all_headers = Off
|
|||
show_login_alert = On
|
||||
|
||||
[labs]
|
||||
cache_system_data = On
|
||||
date_from_headers = On
|
||||
allow_message_append = Off
|
||||
login_fault_delay = 1
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
**Editing HTML Template Files**
|
||||
|
||||
1. Edit data/\_data_/\_default_/configs/application.ini
|
||||
2. Set 'cache_system_data' to Off
|
||||
2. Set `[cache] system_data` to Off
|
||||
|
||||
**Release**
|
||||
|
||||
|
|
|
@ -93,15 +93,19 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
{
|
||||
// Workarounds for the changed application structure
|
||||
if ('labs' === $sSectionKey) {
|
||||
if (\str_contains($sParamKey, 'imap_')) {
|
||||
if (\str_starts_with($sParamKey, 'imap_')) {
|
||||
$sSectionKey = 'imap';
|
||||
$sParamKey = \str_replace('imap_', '', $sParamKey);
|
||||
}
|
||||
if (\str_contains($sParamKey, 'use_app_debug_')) {
|
||||
if (\str_starts_with($sParamKey, 'use_app_debug_')) {
|
||||
$sSectionKey = 'debug';
|
||||
$sParamKey = \str_replace('use_app_debug_js', 'javascript', $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);
|
||||
}
|
||||
|
@ -363,7 +367,9 @@ Enables caching in the system'),
|
|||
'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)'),
|
||||
|
||||
'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(
|
||||
|
@ -376,7 +382,6 @@ Enables caching in the system'),
|
|||
),
|
||||
|
||||
'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.'),
|
||||
'allow_message_append' => array(false),
|
||||
'login_fault_delay' => array(1),
|
||||
|
|
|
@ -150,25 +150,21 @@ abstract class Service
|
|||
|
||||
$oActions = Api::Actions();
|
||||
|
||||
$sThemeName = $oActions->GetTheme($bAdmin);
|
||||
|
||||
$aTemplateParameters = array(
|
||||
'{{BaseAppThemeName}}' => $sThemeName,
|
||||
'{{BaseAppFaviconPngLinkTag}}' => $sFaviconPngLink ? '<link type="image/png" rel="shortcut icon" href="'.$sFaviconPngLink.'">' : '',
|
||||
'{{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'),
|
||||
'{{BaseFavIconSvg}}' => $sFaviconUrl ? '' : Utils::WebStaticPath('favicon.svg'),
|
||||
'{{LoadingDescriptionEsc}}' => \htmlspecialchars($oConfig->Get('webmail', 'loading_description', 'SnappyMail'), ENT_QUOTES|ENT_IGNORE, 'UTF-8'),
|
||||
'{{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'))
|
||||
'{{BaseAppAdmin}}' => $bAdmin ? 1 : 0
|
||||
);
|
||||
|
||||
$sCacheFileName = '';
|
||||
if ($oConfig->Get('labs', 'cache_system_data', true)) {
|
||||
$sCacheFileName = 'TMPL:' . $sLanguage . \md5(
|
||||
if ($oConfig->Get('cache', 'system_data', true)) {
|
||||
$sCacheFileName = 'TMPL:' . $sLanguage . \sha1(
|
||||
Utils::jsonEncode(array(
|
||||
$oConfig->Get('cache', 'index', ''),
|
||||
$oActions->Plugins()->Hash(),
|
||||
|
@ -184,13 +180,17 @@ abstract class Service
|
|||
if ($sResult) {
|
||||
$sResult .= '<!--cached-->';
|
||||
} else {
|
||||
$sThemeName = $oActions->GetTheme($bAdmin);
|
||||
$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['{{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['{{BaseLanguage}}'] = $oActions->compileLanguage($sLanguage, $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 = \strtr($sResult, $aTemplateParameters);
|
||||
if ($sCacheFileName) {
|
||||
|
|
|
@ -422,7 +422,7 @@ class ServiceActions
|
|||
$bAdmin = 'Admin' === (isset($this->aPaths[2]) ? (string) $this->aPaths[2] : 'App');
|
||||
$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) {
|
||||
$this->oActions->verifyCacheByKey($this->sQuery);
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ class ServiceActions
|
|||
$bAppDebug = $this->Config()->Get('debug', 'enable', false);
|
||||
$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) {
|
||||
$this->oActions->verifyCacheByKey($this->sQuery . $sMinify);
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ class ServiceActions
|
|||
$bAppDebug = $this->Config()->Get('debug', 'enable', false);
|
||||
$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) {
|
||||
$this->oActions->verifyCacheByKey($this->sQuery . $sMinify);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue