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)
index.phpCode: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);
When Contao writes cache to disk , it uses following file name (code from FrontendTemplate.php )
Difference only in postfix: $this->Environment->httpAcceptLanguage[0] and $objPage->languageCode: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));
I tried to request index page from 1st browser.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;
/system/tmp folder was empty , so cache file was created
that I requested index page second time , and it was read from cacheCode:md5( 'www.domain.com/empty.en')
that I opened another browser, and requested index page.Code:md5('www.domain.com/empty.en')
Contao tried to read cache from
this file didn't exist, so contao write cache toCode:md5('www.domain.com/empty.ru');
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')Code: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 ...

 
			
 
			
			 How index page caching works
 How index page caching works
				 
					
					
					
						 Reply With Quote
Reply With Quote
Bookmarks