Magento Asked by chdzma on October 2, 2021
I have a question and it is if Magento2 cleans the cache after reindexing data, is it like this?
For example, if the stock in a product is changed and re-indexed. Magento2 clears the cache so that the changes are visible in the fontend?
It is for optimization reasons since the cron schedules for indexing are generated every minute.
I have found more info and directly linked with data changes (index therefore). The cache in Magento is built with tags
.
I will describe an example below that may show the product category listing can reflect the latest products' data without incurring huge costs on the server activity.
Many blocks in Magento 2 do implement the interface MagentoFrameworkDataObjectIdentityInterface
.
I invite you to take a look at these 3 functions:
MagentoCatalogModelCategory::getIdentities
MagentoCatalogBlockProductListProduct::getIdentities
MagentoCatalogModelProduct::getIdentities
Particularly, the second function for the ListProduct Block is very interesting as you can see we are crawling the product collection and check the products 'identities' like a recursive mechanism..
Now, to understand deeply this tag power, it may require practice, I do invite you to create your own tag and then create a block that has data for this tag.. Tags are also visible in the backend (System/Cache Management
) so you should see your tag in the backend once created. Then you can add your custom index but we may accept this may be out of scope here.
we can still learn a lot about cache in Magento looking at: https://github.com/mage2tv/magento-cache-clean. Vinai has spent a fair amount of time on this I believe. . If you have time and want to thoroughly understand the cache, this will help you more than likely.
Answered by Herve Tribouilloy on October 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP