Cleaning (Refreshing) Cache using command

The Magento Admin panel calls it refreshing (Refresh) the cache, while within the code it’s refered to as “cleaning” the cache.

If you want to Refresh your cache within the admin panel, simply go to System > Cache Management.  Drop the box labeled “All cache” down to the Refresh option and hit the Save cache setting button near the upper-right of the window.

If you want to clear your cache from the command line, SSH into your server and get into the base directory of your magento installation.  Type the following commands:

cd var/cache
rm -rf *

If you want to clean the cache from within your code (maybe within a cron or something), you’ll need to place the following PHP code within your script wherever you need the cache cleaned:


I’ve also seen the above written as:


However, the first way is preferred, since it allows for tags to be passed (outside the scope of this post) and also cleans the configuration cache.

If you’re creating a cron file that is outside of your Magento installation, you can use the following method so long as your cron script is running on the same server and has access to the Mage file system:

$mage_filename = '/[YOUR PATH TO MAGENTO]/app/Mage.php';
require_once $mage_filename;