1

I'm having problems with cacheing a block in Magento 2. The theme I'm using is getting content for the block via an AJAX call.

enter image description here

Is it possible and if so, how to cache such a block in M2?

Thank you, Mateusz

0

Every block in magento2 is by default cacheable. You can disable cacheing of that block by explicitly adding cacheable="false" as the block attribute. Can you make sure that this attribute is not added anywhere for this particular block

  • The block itself is stored in cache, but the problem lies in something else. Everytime the block loads, there is an AJAX call made to /productfiler/index/firstload with some parameters. This loads the content of the block and this content is not cached and I need it to be.Do you have any ideas how to change that behaviour? – Mateusz Serotiuk May 17 '17 at 6:42
  • 1
    Either you can stop ajax loading the content and include that content in your block by coping all block information from productfiler_index_firstload to your block that is being cached. Or If you want to keep the ajax call then make sure that all blocks in productfiler_index_firstload.xml are cacheable. That means no block in there can have cacheable false attribute. We can be more helpful if you can provide both xmls – Abhishek Jakhotiya May 17 '17 at 7:15
  • Thanks. The problem is, it's a widget that is placed in a CMS Block and this widget is actually making the AJAX call. And even worse, everything seems to be cached when I look at the code, the AJAX calls are still being made. How would you deal with that? – Mateusz Serotiuk May 17 '17 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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