Cache and cache manage is often one of the least understood functionalities of Magento – Proper cache management can lead to improved store loading times and overall performance. This article is intended to provide both developers and store owners with a greater understanding cache and cache management in Magento 1 stores. This article will also look at understanding the limitations of the Magento cache and how to overcome them.


What are Caches in Magento?

Magento caches allow common components of your store to be cached and quickly referenced when accessed by visitors to your website. Items included in cache range from configuration settings, module data, HTML blocks to more. We’ll look at the types of cache and which objects they store later in this article.

To allow caches to be easily managed and cleared, Magento uses caching ‘Tags’. Particular types of data within your store are grouped together and can be quickly and easily referenced by both Magento and admin users. This process greatly simplifies the process of managing cache types and can be cleared and controlled in the cache management section of your Magento store.


Where are Magento Caches Stored?

All Magento caches are stored in the var/cache/ folder. If your store has a relatively low number of products, you can typically expect 2-3 thousand cache files within your cache file. If you maintain a large Magento store, you can expect anywhere between 10,000 – 20,000 cache files in your cache folder.


Types of cache in Magento


The configuration cache contains data related to non layout modules. Data found within this cache type may include payment gateway configurations and shipping method configurations.


Layout caches store data relating directly to the design layout and associated files. Essential information about layout objects and their positions are all included within this cache along with layout design files and their appearance.

Blocks HTML Output

Content contained within HTML Blocks and static blocks are within the Block HTML output.


If your store uses multiple languages, data relating to individual translations is stored within Magento’s cache.

Collections Data

This contains information about catalog, sales and customer collection

EAV Types and Attributes

This contains information about attributes of all the entities.

Web Services Configuration

This contains information about all 3rd party services which are embedded and integrated in Magento using soap or rest.

Magento uses the Zend Cache Framework as a base for its own cache implementation and these records use the prefix mage—— followed by the ID, the tags and some additional unique identifiers like the first two characters of the md5 hash of the path to the file. This pattern makes each record unique and instantly referable.

When do I need to clear the cache in Magento?

There are typically two primary reasons why you may need to clear the entire cache or particular caches within your Magento Store:

If you’ve made changes to a product, category page or static block this will cause a cache refresh message to display in Magento. Magento is specifically designed to advise users when a cache requires updating and changes to these core data types from within Magento admin will trigger a cache refresh request. For example, changes to product data, won’t require you to refresh the cache relating to to layout or design files.

Additionally, depending on the change you’ve made, Magento will request only the cache associated with the update to be refreshed.

If you made a change the functionality or configuration of a plugin or module on Magento, this may require the cache to be refreshed. If your store includes a delivery matrix for example, after updating the data, you may need to refresh the cache following the import. Magento may not prompt you to refresh this cache, so if you are experiencing any issues on your store following a change, it may be worth checking the cache management system in your Magento admin.

While good cache management in Magento may help improve the speed and performance of your store, if managed incorrectly, flushing aspects of your store cache may result in:

  • Failed Payment Gateway Transactions like Paypal
  • Catalog appearance on frontend
  • Failed custom modules installation
  • Many more issues

How to auto clear Magento Cache

If you run a large store with a high volume of products, refreshing your cache may help improve your site performance. To keep your store running smoothly, we recommend clearing your cache twice per day.

There are a number of Magento modules specifically designed to auto clear store cache at predefined intervals. Alternatively, if you have access to a web developer or certified Magento developer, we recommend auto clearing your cache using a simple, clean server side script.

Script to Auto Clear Magento Cache:

  1. Create a php file with name – ClearCache.php or anything you want


echo “Start Cleaning all caches at … ” . date(“Y-m-d H:i:s”) . “\n\n”;

ini_set(“display_errors”, 1); //Display Errors if anything gone wrong

require ‘app/Mage.php’; // Include Magento Inbuilt Functions

Mage::app(‘admin’)->setUseSessionInUrl(false); //get Admin Session

Mage::getConfig()->init(); //Initialised

$types = Mage::app()->getCacheInstance()->getTypes(); //Get all Magento Cache Types

try {

echo “Cleaning data cache… \n”; //Cleaning Data Cache

flush(); //Flush all caches

foreach ($types as $type => $data) {

echo “Removing $type … “;

echo Mage::app()->getCacheInstance()->clean($data[“tags”]) ? “Cache cleared!” : “There is some error!”;

echo “\n”;


} catch (exception $e) {

die(“[ERROR:” . $e->getMessage() . “]”);


echo “\n”;

try {

echo “Cleaning stored cache… “; //Cleaning Stored Cache


echo Mage::app()->getCacheInstance()->flush() ? “Cache cleared!” : “There is some error!”;

echo “\n\n”;

} catch (exception $e) {

die(“[ERROR:” . $e->getMessage() . “]”);



Place this file into the root location

  1. Cronjob – Navigate to document root of your site and execute crontab -e

Press ‘i’ to insert

Write * /50 * * * * /usr/bin/php -q /path/to/your/documment/root/ClearCache.php  > /path/to/your/documment/root/var/log/ClearCache.log

Here we have instructed Cron to execute the script after every 50 minutes. You can change it to anything you want in the format (minutes) (hours) (day of month) (month) (day of week) (command)

Type Esc + wq + Enter to save

And you’re done! As you’ve probably noticed, we are not deleting any of the caches from the directory, we are doing it by using the inbuilt Cache Class in Magento so this is the safest, simplest and most probably the easiest approach to take.