启用FPC缓存后,会话值不起作用



启用FPC缓存时,会话值在块中不起作用。如何处理启用缓存块中的会话值。我在下面添加了客户会话ID。如何从在一个街区中的缓存。

public function getCacheKeyInfo() {
    $info = parent::getCacheKeyInfo();
    $info['current_product_id'] = Mage::registry('current_product')->getId();
    $info['customer_id'] = Mage::getSingleton('customer/session')->getCustomerId();
    return $info;
}

在这种情况下,您需要从getCacheKey方法返回自定义值,例如:

public function getCacheKey(){
    if (Mage::getSingleton('customer/session')->getCustomerId() == '') {
        return 'custom_cache_key_not_loggedin';
    } else {
        return 'custom_cache_key_' . Mage::getSingleton('customer/session')->getCustomerId();
    }
}

,请记住,如果启用了您的FPC(全页缓存),则不会产生任何效果。因为整页缓存不是您的问题所要求的。

如果我在哪里,该怎么办?

在您的情况下,我希望在用户为loggedin时跳过特定的(用户)块。

最新更新