Skip to content

Instantly share code, notes, and snippets.

@gelanivishal
Last active February 21, 2017 01:37
Show Gist options
  • Save gelanivishal/1f765596257c77f8bc1b7362e4744082 to your computer and use it in GitHub Desktop.
Save gelanivishal/1f765596257c77f8bc1b7362e4744082 to your computer and use it in GitHub Desktop.
M1 - Clear cache programatically
<?php
//increase execution time
ini_set('max_execution_time', 900); //900 seconds = 15 minutes
//require Magento
require_once 'app/Mage.php';
$app = Mage::app('admin');
umask(0);
//enable Error Reporting
error_reporting(E_ALL & ~E_NOTICE);
try {
//CLEAN OVERALL CACHE
flush();
Mage::app()->cleanCache();
// CLEAN IMAGE CACHE
flush();
Mage::getModel('catalog/product_image')->clearCache();
//print
print 'done';
}
catch(Exception $e) {
//something went wrong...
print($e->getMessage());
}
?>
<?php
//increase execution time
ini_set('max_execution_time', 900); //900 seconds = 15 minutes
//require Magento
require_once 'app/Mage.php';
$app = Mage::app('admin');
umask(0);
//enable Error Reporting
error_reporting(E_ALL & ~E_NOTICE);
$types=array('config','layout','block_html','translate','collections','eav','config_api','config_api2');
foreach($types as $type) {
$c = Mage::app()->getCacheInstance()->cleanType($type);
Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => $type));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment