Hello,
I have run across a problem: home page generates very high system load.
I found out that index page calls (not all) executes about 170 sql queries every time.
Contao use following file name for reading page from cache (code from index.php)
Code:
if ($this->Environment->request == '' || $this->Environment->request == 'index.php')
{
$strCacheKey = $this->Environment->base .'empty.'. $this->Environment->httpAcceptLanguage[0];
}
else
{
$strCacheKey = $this->Environment->base . $this->Environment->request;
}
$strCacheFile = TL_ROOT . '/system/tmp/' . md5($strCacheKey);
index.php
When Contao writes cache to disk , it uses following file name (code from FrontendTemplate.php )
Code:
if ($this->Environment->request == '' || $this->Environment->request == 'index.php')
{
$strUniqueKey = $this->Environment->base . 'empty.' . $objPage->language;
}
else
{
$strUniqueKey = $this->Environment->base . $strUrl;
}
$objFile = new File('system/tmp/' . md5($strUniqueKey));
Difference only in postfix: $this->Environment->httpAcceptLanguage[0] and $objPage->language
Code:
// here contao define key for reading from cache
$strCacheKey = $this->Environment->base .'empty.'. $this->Environment->httpAcceptLanguage[0];
// here contao define key for writing to cache
$strUniqueKey = $this->Environment->base . 'empty.' . $objPage->language;
I tried to request index page from 1st browser.
/system/tmp folder was empty , so cache file was created
Code:
md5( 'www.domain.com/empty.en')
that I requested index page second time , and it was read from cache
Code:
md5('www.domain.com/empty.en')
that I opened another browser, and requested index page.
Contao tried to read cache from
Code:
md5('www.domain.com/empty.ru');
this file didn't exist, so contao write cache to
Code:
md5('www.domain.com/empty.en')
Contao tries to read cache from md5('www.domain.com/empty.ru') , it doesn't exists, Contao generates page and writes cache to md5('www.domain.com/empty.en')
In my case cache doesn't work because httpAcceptLanguage and objPage->language are different.
Is it normal behavior , and can it be fixed without scripts changing?
I fixed that, but not sure that is right way:
Code:
if ($this->Environment->request == '' || $this->Environment->request == 'index.php')
{
$strCacheKey = $this->Environment->base .'empty.en';
}
else
...
Bookmarks