Results 1 to 3 of 3

Thread: How index page caching works

  1. #1
    New user
    Join Date
    10-18-10.
    Posts
    10

    Default How index page caching works

    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
    ...

  2. #2
    User
    Join Date
    06-19-09.
    Location
    Elbl?g, Poland
    Posts
    152

    Default Re: How index page caching works

    Interesting... maybe you should create ticket at http://dev.contao.org
    Marcin

    http://www.contao.pl - Polish Support Site
    http://forum.contao.pl - Polish Contao community forum


    -----------------------
    Need custom template? Feel free to contact me by e-mail marcin@contao.pl

  3. #3

    Default Re: How index page caching works

    I thought this has been dealt with since version 2.9.1, It was a very long discussion in German forum (http://www.contao-community.de/showthre ... #post79882). Though you may not understand german, but look into the code snippet in this threat, you may get the idea.
    But anyway create ticket and let clear the things up.
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •