mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
Additional configurations and improvements for caching system (#1390)
This commit is contained in:
parent
7b3ac82e5a
commit
bf1ee5ace7
3 changed files with 824 additions and 808 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -8329,6 +8329,16 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
||||||
return \in_array($sName, $this->Capa($bAdmin, $bMobile, $oAccount));
|
return \in_array($sName, $this->Capa($bAdmin, $bMobile, $oAccount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sKey
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function etag($sKey)
|
||||||
|
{
|
||||||
|
return \md5('Etag:'.\md5($sKey.\md5($this->Config()->Get('cache', 'index', ''))));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $sKey
|
* @param string $sKey
|
||||||
* @param bool $bForce = false
|
* @param bool $bForce = false
|
||||||
|
|
@ -8338,13 +8348,19 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
||||||
public function cacheByKey($sKey, $bForce = false)
|
public function cacheByKey($sKey, $bForce = false)
|
||||||
{
|
{
|
||||||
$bResult = false;
|
$bResult = false;
|
||||||
if (!empty($sKey) && ($bForce || $this->Config()->Get('cache', 'enable', true) && $this->Config()->Get('cache', 'http', true)))
|
if (!empty($sKey) && ($bForce || ($this->Config()->Get('cache', 'enable', true) && $this->Config()->Get('cache', 'http', true))))
|
||||||
{
|
{
|
||||||
$this->oHttp->ServerUseCache(
|
$iExpires = $this->Config()->Get('cache', 'http_expires', 3600);
|
||||||
\md5('Etag:'.\md5($sKey.\md5($this->Config()->Get('cache', 'index', '')))),
|
if (0 < $iExpires)
|
||||||
1382478804, 2002478804);
|
{
|
||||||
|
$this->oHttp->ServerUseCache($this->etag($sKey), 1382478804, time() + $iExpires);
|
||||||
|
$bResult = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$bResult = true;
|
if (!$bResult)
|
||||||
|
{
|
||||||
|
$this->oHttp->ServerNoCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bResult;
|
return $bResult;
|
||||||
|
|
@ -8360,10 +8376,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
||||||
{
|
{
|
||||||
if (!empty($sKey) && ($bForce || $this->Config()->Get('cache', 'enable', true) && $this->Config()->Get('cache', 'http', true)))
|
if (!empty($sKey) && ($bForce || $this->Config()->Get('cache', 'enable', true) && $this->Config()->Get('cache', 'http', true)))
|
||||||
{
|
{
|
||||||
$sIfModifiedSince = $this->Http()->GetHeader('If-Modified-Since', '');
|
|
||||||
$sIfNoneMatch = $this->Http()->GetHeader('If-None-Match', '');
|
$sIfNoneMatch = $this->Http()->GetHeader('If-None-Match', '');
|
||||||
|
if ($this->etag($sKey) === $sIfNoneMatch)
|
||||||
if (!empty($sIfModifiedSince) || !empty($sIfNoneMatch))
|
|
||||||
{
|
{
|
||||||
$this->Http()->StatusHeader(304);
|
$this->Http()->StatusHeader(304);
|
||||||
$this->cacheByKey($sKey);
|
$this->cacheByKey($sKey);
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,8 @@ Enables caching in the system'),
|
||||||
'fast_cache_index' => array('v1', 'Additional caching key. If changed, fast cache is purged'),
|
'fast_cache_index' => array('v1', 'Additional caching key. If changed, fast cache is purged'),
|
||||||
|
|
||||||
'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)'),
|
||||||
|
|
||||||
'server_uids' => array(true, 'Caching message UIDs when searching and sorting (threading)')
|
'server_uids' => array(true, 'Caching message UIDs when searching and sorting (threading)')
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue