The recent home is very slow, run Magento profile check, found that the first page of a templat run time accounted for half, about 6s.
With Magento's own cache, try to cache the code in collection, but don't know why it has failed, and finally decided to turn the entire template into a static page, regenerated every two hours.
The code is as follows:
<?PHP$dir= Mage::getbasedir (). DS. ' var '.DS;$fileName=$dir.‘ Real_static_categories.phtml ';if(!file_exists($fileName)|| (Filemtime($fileName) && ( Time()-Filemtime($fileName) >7200))){ $text=mage::app ()->getlayout ()->createblock (' Catalog/product_list ')->settemplate (' catalog/product/ Productcarousel/carouselblocks/categories.phtml ')toHtml (); $file=fopen($fileName, ' W '); fwrite($file,$text); fclose($file);}$file=fopen($fileName, ' R ');Echo fread($file,filesize($fileName));fclose($file);?>
The effect is good, and the access speed is increased by one times.
Magento optimization Template static