我们正在使用 Magento EE 1.9。
为了加快客户端网站的速度,我们正在尝试微调缓存。
如您所知,Magento 带有不同的缓存技术。
在 Magento EE 中,我们可以使用全页缓存以及名为“打孔”的技术。据我了解,这个缓存使用了一些容器来确定是否应该从缓存中检索动态块 => applyWithoutApp($content) 或者是否应该使用 $this->_renderBlock() => applyWithApp 实例化和呈现动态块($内容)
为此,您必须在 cache.xml 中声明要“打孔”的块,其中包括扩展 Enterprise_PageCache_Model_Container_Abstract 的适当容器类在此容器类中,您必须实现不同的功能,如 _getIdentifier()、_getCacheId()、 _renderBlock 如您所见,Contanier 拥有自己的缓存 ID。
正如这里所解释的
http://www.magentocommerce.com/wiki/5__-_modules_and_development/block_cache_and_html_ouput 要缓存一个块,您只需通过定义 cache_lifetime、cache_tags、cache_key 直接在 bloc 的构造函数中添加数据
class {NS}_{Module}_Block_{View} extends Mage_Core_Block_Template {
protected function _construct()
{
$this->addData(array(
'cache_lifetime' => 120,
'cache_tags' => array(Mage_Catalog_Model_Product::CACHE_TAG . "_" . $this->getProduct()->getId()),
'cache_key' => $this->getProduct()->getId(),
));
}
}
使用以下帖子进行编辑 http://magebase.com/magento-tutorials/adding-cache-support-to-magento-blocks/
我知道静态的“cache_key”是不够的。对于这些 cas,我们应该使用 getCacheKeyInfo 方法:
public function getCacheKeyInfo()
{
return array(
'EXAMPLE_BLOCK',
Mage::app()->getStore()->getId(),
(int)Mage::app()->getStore()->isCurrentlySecure(),
Mage::getDesign()->getPackageName(),
Mage::getDesign()->getTheme('template')
);
}
所有这一切我回到我的问题:据我所知,FPC + 打孔似乎是“缓存”的更完整解决方案。但是全页缓存(带有打孔)和“经典”块缓存有什么区别?
-> 由于我们使用的是 Magento EE 1.9,我们应该只使用 FPC + 打孔吗?
(因为在某种程度上 FPC + 打孔已经是缓存块的一种方式?)
- 这是否意味着“经典”块缓存已经过时或仅适用于 magento 社区版的用户?
-> 还是我们应该同时使用(FPC + 打孔和经典块缓存)?
- 在这种情况下,当一个块有自己的缓存键(或 getCacheKeyInfo())时,为容器设置缓存 id 有什么意义?
- 在这种情况下,这些缓存方法中的哪一种是主要的?
提前感谢您的所有回答!