1

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

enter image description here

Is it possible how to cache such block in M2?

Thank you, Mateusz

1 Answer 1

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

3
  • 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? May 17, 2017 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 May 17, 2017 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? May 17, 2017 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.