如何在magento中缓存cms块以进行会话和非会话访问?
对于 Magento 企业网站,我有一个 CMS 页面(主页),其中包含某个代码块“my-products.phtml”,在 CMS 页面内容中使用以下方法:
{{block type="catalog/product_list" template="catalog/product/my-products.phtml"}}
问题是该块确实是真的速度慢,需要缓存。包含的 CMS 页面会为非会话访问者缓存,但一旦用户登录,该页面和包含的块似乎根本不会被缓存。
该块内没有特定于会话的代码,因此我想知道如何确保即使用户登录也能缓存它?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要创建
Mage_Catalog_Block_Product_List
的后代,并使用它的块类型别名,例如“yourmodule/product_list”而不是“catalog/product_list”。按照这些说明启用其缓存,给出的第一个示例正是您所需要的显示一些产品相关数据,但使用更长的生命周期来提高效率。
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.