Ive noticed my home page is taking a long time to load - over 6 seconds infact according site24x7.com, so ive been switching elements off to try and determine what is the cause, and it is down to 2 product collection files I have made to show new products and best selling products.
As soon as i remove these from the home page, the page loads in less than .5 seconds.
So, can anyone help with optimising and caching a productCollection? I have APC installed and running on the server, but Im not sure it is caching the files located in app/design/frontend/default/MY_THEME/catalog/product/newproducts.phtml
So, my collection call for best selling (most viewed actually) looks like this;
<?php $storeId = Mage::app()->getStore()->getId(); // return current store id ?>
<?php $_productCollection= Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addStoreFilter($storeId)
->addViewsCount()
->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->addFieldToFilter('status',Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
$_productCollection->getSelect()->limit(8)
?>
How can I further optimise this?
urlencode
twice? Is it necessary or is it a bug here? Shouldn't this be:$data = urlencode(serialize($array)); $cache->save($data, $key, array("homepage_cache"), 60*60*24);
? – Fetish