user672201
user672201

Reputation: 31

how to cache cms block in magento for sessioned and non-sessioned visits?

For a Magento enterprise site, I have a CMS page (home page) which includes a certain block of code, 'my-products.phtml', using the following method within the CMS page content:

{{block type="catalog/product_list" template="catalog/product/my-products.phtml"}}

The problem is that this block is really really slow and needs to be cached. The containing CMS page is cached for non-sessioned visitors, but once a user logs in, the page and the included block don't seem to be cached at all.

There's no session-specific code within the block so I'm wondering how to ensure that it is cached even when a user is logged in?

Upvotes: 3

Views: 1643

Answers (1)

clockworkgeek
clockworkgeek

Reputation: 37700

You need to create a descendant of Mage_Catalog_Block_Product_List and use it's alias for the block type, like "yourmodule/product_list" instead of "catalog/product_list".

Follow these instructions to enable it's cache, the first example given is exactly what you need to display some product related data, but use a larger lifetime for more efficiency.

Upvotes: 1

Related Questions