Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    Flush Cache by Tag in Magento 2

    Magento 2 have excellent cache mechanism. There are different types of cache, caches have id, there are tags to group caches and even Magento allows to create custom cache type. All of these makes a very good mechanism for caching. 

    We can flush Magento cache by types from Admin panel and command line. But what if we want to clean the cache only partially. We can do it by cleaning cache by tag. 

    Let’s suppose we make any changes in a particular product or category or let’s suppose we show some data on product page like in our Magento 2 Auction module we show the auction related data on the product page. And every times someone bid on the product the data gets changed but it will not reflect untill we flush or clean the cache. 

    We can flush and clean the cache programmatically as in “How to clean and flush cache programmatically in magento2”  to reflect the changes but it will remove the other static content, other blocks which were not updated and all the pages from cache. So how do we clean the cache only for that particular product and only the product related container and not header and footer? Solution to this problem is cleaning cache by tag. 

    So now let see how can we clean caches partially with tags,

    Here we have cleaned a product page cache whose id is 21. Similarly you can clear s category page cache by using “CAT_C” as prefix. So it will be like CAT_C_3, where 3 is the category id. And in same way you can find tags for other pages to clean.

    Thanks for reading blog. Feel free to comment.

    . . .

    Comments (2)

    Add Your Comment

  • rajeshwari
    Yes, Magento2 extension is very useful for marketpace development for e-commerce.
  • Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again