In the world of eCommerce, your website performance matters as much as your product quality. If you offer top-quality products but the website is lacking in speed or functionality, your store’s performance will be quite limited. The reason is competition. With so many eCommerce stores popping up, the concept of brand loyalty is eroding. Therefore, to beat the competition, you must always be one step ahead.
One way to improve your Magento store’s performance is through the ‘Clear Magento 2 Cache’ function. Cache Clean in Magento 2 ensures loading, formatting, and other issues are resolved, thereby enhancing the user experience. Clearing Magento cache is something every Magento store owner needs to learn.
You don’t need to have a technical background to clear the cache. Instead, all you need is a learning attitude and go through this guide with full attention. This step-by-step guide will help you understand how to effectively clear Magento 2 cache without asking your developer for it.
<?php use Magento\Framework\App\PageCache\Version; use Magento\Framework\App\Cache\TypeListInterface; use Magento\Framework\App\Cache\Frontend\Pool; protected $cacheTypeList; protected $cacheFrontendPool; public function __construct(TypeListInterface $cacheTypeList, Pool $cacheFrontendPool){ $this->cacheTypeList = $cacheTypeList; $this->cacheFrontendPool = $cacheFrontendPool; } public function cacheFunction(Version $subject) { $types = array('config','layout','block_html','collections','reflection','db_ddl','eav','config_integration','config_integration_api','full_page','translate','config_webservice'); foreach ($types as $type) { $this->cacheTypeList->cleanType($type); } foreach ($this->cacheFrontendPool as $cacheFrontend) { $cacheFrontend->getBackend()->clean(); } }
Now go to Admin Panel> System> Cache Management. Over there you will see 2 big buttons on the top. The first one will Flush Magento Cache and the second one will Flush Cache Storage. Click on both to clear Magento Cache and Cache Storage for your website.
By clicking “Flush Magento Cache” all the default Magento Cache items that have Magento tag will be removed.
By clicking “Flush Cache Storage” all the items from Cache with Magento tag and without it will be removed.
Magento 2.0 has another method as well to Flush Catalog Images Cache and JavaScript/CSS Cache.
Navigate to Admin Panel> System> Cache Management and you will see the options at the bottom of the page as shown below.
The first option will remove the catalog images from all sections such as media/catalog/product/cache. The second option will remove the JavaScript copy and CSS files from the Cache of your Magento 2 storeCongratulations! You have successfully cleared Magento 2 cache and learned to do it all by yourself. Now you can easily add your content and reflect them on your front-end store without any over complicated procedures. If you run into trouble when clearing the cache, reach out to us. Our Magento development experts will address your queries promptly and to your satisfaction.
This blog was created with FME's SEO-friendly blog