{"issue":{"created_at":"2011-11-29T10:02:55Z","state":"closed","updated_at":"2011-11-29T10:02:59Z","user":{"gravatar_id":"256406243346b9253f8610fb1d1e05f6","id":1215373,"url":"https://api.github.com/users/importer","avatar_url":"https://secure.gravatar.com/avatar/256406243346b9253f8610fb1d1e05f6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"importer"},"comments":2,"body":"Hello,\n\nI have run across a problem:  home page generates very high system load.\nI found out that index page calls (not all) executes about 170 sql queries every time.\n\nContao use following file name for reading page from cache (code from index.php)\n\n```\nif ($this->Environment->request == '' || $this->Environment->request == 'index.php')\n{\n\t$strCacheKey = $this->Environment->base .'empty.'. $this->Environment->httpAcceptLanguage[0];\n}\nelse\n{\n\t$strCacheKey = $this->Environment->base . $this->Environment->request;\n}\n$strCacheFile = TL_ROOT . '/system/tmp/' . md5($strCacheKey);\n```\n\nWhen Contao writes cache to disk , it uses following file name (code from FrontendTemplate.php )\n\n```\nif ($this->Environment->request == '' || $this->Environment->request == 'index.php')\n{\n\t$strUniqueKey = $this->Environment->base . 'empty.' . $objPage->language;\n}\nelse\n{\n\t$strUniqueKey = $this->Environment->base . $strUrl;\n}\n$objFile = new File('system/tmp/' . md5($strUniqueKey));\n```\n\nDifference only in postfix:  $this->Environment->httpAcceptLanguage[0] and $objPage->language\n\n```\n// here contao define key for reading from cache\n$strCacheKey = $this->Environment->base .'empty.'. $this->Environment->httpAcceptLanguage[0];\n\n// here contao define key for writing to cache\n$strUniqueKey = $this->Environment->base . 'empty.' . $objPage->language;\n```\n\nI tried to request index page from 1st browser.\n/system/tmp folder was empty , so cache file was created\n\n```\nmd5( 'www.domain.com/empty.en')\n```\n\nthat I requested index page second time , and it was read from cache \n\n```\nmd5('www.domain.com/empty.en')\n```\n\nthat I opened another browser, and requested index page.\nContao tried to read cache from \n\n```\nmd5('www.domain.com/empty.ru');\n```\n\nthis file doesn't exist, so contao write cache to \n\n```\nmd5('www.domain.com/empty.en')\n```\n\nContao tries to read cache from md5('www.domain.com/empty.[u]ru[/u]') , it doesn't exists, Contao generates page and writes cache to md5('www.domain.com/empty.en')\n\nIn my case cache doesn't work because httpAcceptLanguage and objPage->language are different.\n\n\nI applied temporary fix\n\n```\nif ($this->Environment->request == '' || $this->Environment->request == 'index.php')\n{\n\t$strCacheKey = $this->Environment->base .'empty.en';\n}\nelse\n...\n```\n\n--- _Originally created by igolikov on November 2nd, 2010, at 02:25pm (ID 2654)_","assignee":null,"id":2382410,"number":2654,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[{"name":"Defect","color":"bd2c00","url":"https://api.github.com/repos/contao/test/labels/Defect"},{"name":"frontend","color":"e6e6e6","url":"https://api.github.com/repos/contao/test/labels/frontend"},{"name":"Invalid","color":"ffdd00","url":"https://api.github.com/repos/contao/test/labels/Invalid"}],"title":"index page caching ","closed_at":"2011-11-29T10:02:59Z","html_url":"https://github.com/contao/test/issues/2654","url":"https://api.github.com/repos/contao/test/issues/2654","milestone":null},"action":"closed"}