{"id":111,"date":"2018-06-01T10:56:16","date_gmt":"2018-06-01T10:56:16","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2018\/06\/01\/clear-magento-2-cache\/"},"modified":"2025-07-24T16:07:46","modified_gmt":"2025-07-24T10:37:46","slug":"clear-magento-2-cache","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/clear-magento-2-cache\/","title":{"rendered":"How to Clear Magento 2 Cache"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Cache is a particular area of your hosting server. It helps to increase the page load speed by storing the web pages through browsers. Also, it reduces resource requirements in the situation of heavy traffic.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The basic advantage of using cache is faster performance. If you are unsure of why the changes made on the website don\u2019t reflect, the very first step you should try is to&nbsp;refresh the cache to reflect those changes in the frontend.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Everyone wants the fastest way to delete cache in Magento 2! Here are the three methods for&nbsp;<em><strong>Magento 2 Clear Cache&nbsp;<\/strong><\/em>which might prove useful to you  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"admin\">Method 1: Clear Magento 2 Cache via Admin Panel<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Navigate to&nbsp;<strong>Admin Panel &gt; System &gt; Cache Management<\/strong><\/li>\n\n\n\n<li>Define the cache types that is to be refreshed<\/li>\n\n\n\n<li>Select the Cache Type blocks that are assigned Invalidated status. You may select \u201c<strong>All<\/strong>\u201d if you don\u2019t know what to refresh.<\/li>\n\n\n\n<li>Set the \u201c<strong>Refresh<\/strong>\u201d action and click on the \u201c<strong>Submit<\/strong>\u201d button.<\/li>\n\n\n\n<li>Additionally, you may use \u201c<strong>Flush Magento Cache<\/strong>\u201d or \u201c<strong>Flush Cache Storage<\/strong>\u201d buttons.\n<ul class=\"wp-block-list\">\n<li><strong>Flush Magento Cache:<\/strong>&nbsp;Refresh the cache in the backend and inner cache with Magento tag.<\/li>\n\n\n\n<li><strong>Flush Cache Storage:<\/strong>&nbsp;Refresh cache of all Magento stores sharing one cache storage, though based on different servers.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2018\/06\/clear-cache-from-admin-panel.png\" alt=\"clear cache from admin panel\" class=\"wp-image-3094\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"CLI\">Method 2: Magento 2 Clear Cache via Command Line<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can delete cache manually using the below commands from Command Line:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enable the cache:<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">php bin\/magento cache:enable<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Disable the cache:<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">php bin\/magento cache:disable<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Flush the cache:<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">php bin\/magento cache:flush<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Clean the cache in the website:<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">php bin\/magento cache:clean<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To clean specific cache types, you need to specify the types, e.g.:&nbsp;<em>config, layout, block_html, collections, reflection, db_ddl, eav,<\/em>&nbsp;etc.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"code\">Method 3: Magento 2 Clear Cache Programmatically<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Store admin may have the requirements to&nbsp;<em><strong>clean and flush cache programmatically in Magento 2<\/strong><\/em>. It is advisable to implement it in order to offer a speedy store to store users.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nuse Magento\\Framework\\App\\PageCache\\Version;\nuse Magento\\Framework\\App\\Cache\\TypeListInterface;\nuse Magento\\Framework\\App\\Cache\\Frontend\\Pool;\nprotected $cacheTypeList;\nprotected $cacheFrontendPool;\n\npublic function __construct(TypeListInterface $cacheTypeList,\nPool $cacheFrontendPool){\n    $this->cacheTypeList = $cacheTypeList;\n    $this->cacheFrontendPool = $cacheFrontendPool;\n\n}\n\npublic function cacheFunction(Version $subject)\n{\n  $types = array('config','layout','block_html','collections','reflection','db_ddl','eav','config_integration','config_integration_api','full_page','translate','config_webservice');\n\n    foreach ($types as $type) {\n        $this->cacheTypeList->cleanType($type);\n    }\n    foreach ($this->cacheFrontendPool as $cacheFrontend) {\n        $cacheFrontend->getBackend()->clean();\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"fpc\">Full Page Cache<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Enable Full Page Cache to enhance the performance of your website and increase the page load speed:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Navigate to&nbsp;<strong>Stores&nbsp;<\/strong>&gt;&nbsp;<strong>Configuration&nbsp;<\/strong>&gt;&nbsp;<strong>Advanced&nbsp;<\/strong>&gt;&nbsp;<strong>System&nbsp;<\/strong>&gt;&nbsp;<strong>Full Page Cache<\/strong><\/li>\n\n\n\n<li>Choose either&nbsp;<strong>Built-In Cache<\/strong>&nbsp;or&nbsp;<strong>Varnish Cache<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:&nbsp;<\/strong>Varnish&nbsp;cache is 4 to 9 times faster than Built-In Cache<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2023\/06\/Full-page-cache.png\" alt=\"Full page caching in Magento 2 store\" class=\"wp-image-32636\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">You can implement the Full Page Cache Warmer for Magento 2. The module allows for speeding up your online store due to timely cache warming whenever needed. Also, you can exclude separate pages from warming and enable the auto-update cache after changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"diff\">Know the difference between Magento 2 cache clean and cache flush:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Magento 2 Clean Cache:<\/strong>&nbsp;Deletes all enabled Cache type from Magento 2 due to which the disabled cache types are not cleaned.<br><strong>Magento 2 Flush Cache:<\/strong>&nbsp;Cleans all the cache types collected in storage. It may affect other processing applications that run the same cache storage.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"enable\">How to enable Cache Types?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For clearing specific cache types which have not been assigned Invalidated status, go to&nbsp;<strong>Cache Management<\/strong>&nbsp;and configure the following settings:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select the cache types you want to enable.<\/li>\n\n\n\n<li>Set Enable from the upper left drop-down menu.<\/li>\n\n\n\n<li>Click \u201c<strong>Submit<\/strong>\u201d button.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2018\/06\/enabling-cache.png\" alt=\"enabling cache types\" class=\"wp-image-3097\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all about&nbsp;<em><strong>Clearing&nbsp;<\/strong><\/em><em><strong>Magento 2 Cache<\/strong><\/em>! I have tried to elaborate basic Magento 2 cache concepts, apply methods to cache your Magento 2 store and improve store performance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Happy Caching.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cache is a particular area of your hosting server. It helps to increase the page load speed by storing the web pages through browsers. Also,&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-111","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=111"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":15654,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/111\/revisions\/15654"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}