Last active
December 23, 2021 10:25
-
-
Save keithgreer/1121f6a08ad6033272dd21274159eac8 to your computer and use it in GitHub Desktop.
Magento 2 Cache Refresh Script - https://keithgreer.dev/magento-2-cache-refresh-script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Magento\Framework\App\Bootstrap; | |
include('app/bootstrap.php'); // Update as required, this line will work if placed in the Magento Root Directory | |
$bootstrap = Bootstrap::create(BP, $_SERVER); | |
$objectManager = $bootstrap->getObjectManager(); | |
?><div style='top:45%; position:absolute; width:75%; text-align:center; color:#666; font-weight:bold; font-size:1.8em; '><?php | |
try{ | |
$_cacheTypeList = $objectManager->create('Magento\Framework\App\Cache\TypeListInterface'); | |
$_cacheFrontendPool = $objectManager->create('Magento\Framework\App\Cache\Frontend\Pool'); | |
$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) { | |
$_cacheTypeList->cleanType($type); | |
} | |
foreach ($_cacheFrontendPool as $cacheFrontend) { | |
$cacheFrontend->getBackend()->clean(); | |
} | |
?><span style='color:green'>● Success. </span> The cache has been cleared. <?php | |
}catch(Exception $e){ | |
?><span style='color:red'>● Error. </span><?php | |
echo $msg = 'Error : '.$e->getMessage();die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment