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));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function etag($sKey)
|
||||
{
|
||||
return \md5('Etag:'.\md5($sKey.\md5($this->Config()->Get('cache', 'index', ''))));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
* @param bool $bForce = false
|
||||
|
|
@ -8338,13 +8348,19 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
|||
public function cacheByKey($sKey, $bForce = 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(
|
||||
\md5('Etag:'.\md5($sKey.\md5($this->Config()->Get('cache', 'index', '')))),
|
||||
1382478804, 2002478804);
|
||||
$iExpires = $this->Config()->Get('cache', 'http_expires', 3600);
|
||||
if (0 < $iExpires)
|
||||
{
|
||||
$this->oHttp->ServerUseCache($this->etag($sKey), 1382478804, time() + $iExpires);
|
||||
$bResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
$bResult = true;
|
||||
if (!$bResult)
|
||||
{
|
||||
$this->oHttp->ServerNoCache();
|
||||
}
|
||||
|
||||
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)))
|
||||
{
|
||||
$sIfModifiedSince = $this->Http()->GetHeader('If-Modified-Since', '');
|
||||
$sIfNoneMatch = $this->Http()->GetHeader('If-None-Match', '');
|
||||
|
||||
if (!empty($sIfModifiedSince) || !empty($sIfNoneMatch))
|
||||
if ($this->etag($sKey) === $sIfNoneMatch)
|
||||
{
|
||||
$this->Http()->StatusHeader(304);
|
||||
$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'),
|
||||
|
||||
'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)')
|
||||
),
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue