【问题标题】:Disabling cache for Magento Block in APC在 APC 中禁用 Magento Block 的缓存
【发布时间】:2023-03-12 18:33:01
【问题描述】:

我正在使用安装了 APC 缓存的 Magento CE v.1.9.0。我需要为块输出禁用缓存,但不幸的是,标准解决方案对我不起作用:

    $this->addData(array(
            'cache_lifetime' => 0,
            'cache_key'      => Mage::registry('current_product')->getId() . '_testcache',
        ));

块仍在缓存中。任何建议,我怎么能做到这一点,而不实施生病的 AJAX 解决方案?谢谢。

【问题讨论】:

    标签: magento caching apc


    【解决方案1】:

    您可以尝试通过您的布局 xml 之一禁用它。

    <reference name="block_name">            
      <action method="unsetData"><key>cache_lifetime</key></action>
    </reference>
    

    【讨论】:

      【解决方案2】:

      最简单的方法是在当前块上设置 setCacheLifetime。

      因此,您需要在当前布局文件中将生命周期设置为 0 或 null(0 是更正确的方式)。

      <reference name="needed block">
             <action method="setCacheLifetime"><s>0</s></action>
         </reference>
      

      【讨论】:

      • 子程序回答对我有帮助,但我认为这也可以,谢谢。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-17
      • 1970-01-01
      • 2011-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      相关资源
      最近更新 更多