I need to remove the product_list block from cache Class: Magento\Catalog\Block\Product\ListProduct Block: /var/www/html/vendor/magento/module-catalog/view/frontend/templates/product/list.phtml

I have tried these solutions:

public function getCacheLifetime()
    return null;

I have tried $_isScopePrivate = true; too.

Nothing seems to be working. I need to update the product collection on category list page based upon user input, so I need to remove the block from cache. Please help.


1 Answer 1


Are you sure, that this is a good idea? because all pages with non cached blocks are excluded from full page caching. in your case, all category pages are excluded from full page caching. i think, you have to solve your problem with dynamic loaded content.

if you really want to disable the cache for a specific magento block, you can do it in a xml file. See here.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
      <referenceContainer name="category.products">
         <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" template="Magento_Catalog::product/list.phtml" cacheable="false"/>
  • Hi, putting cacheable="false" will remove entire page from cache, won't it?
    – Manish Joy
    Jul 1, 2022 at 8:44
  • yes. all pages with a non cacheable block on it are excluded from full page cache. Jul 1, 2022 at 9:25
  • So, this is not what I need to achieve. I just need my block out of the cache which is not working for me.
    – Manish Joy
    Jul 1, 2022 at 9:36
  • yes, but if you have just one block on a page, the whole page is excluded from full page cache. this is a magento behavior. if you can live with that, try the xml solution in my answer to exclude the block from cache. Jul 1, 2022 at 11:38
  • Sorry, this solution won't work as we definitely cannot exclude entire page from FPC.
    – Manish Joy
    Jul 5, 2022 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.