Friday 11 May 2012

How to clear the cache using code in Magento?


If you have made any modifications to your Magento store, they will not appear immediately unless you clear the cache.
Magento keeps its cache in /var/cache located inside the Magento installation directory. So, for example, if your Magento is installed in your main public_html folder, the cache will be in public_html/var/cache.
To clear the cache, simply delete everything from the /var/cache directory and then reload your website in your browser.
To clear all sessions, you can also delete everything from the /var/session folder within your Magento installation directory.
To clear cache in Magento using code, you can use one of some methods below:
Clear all cache files of Magento by the command: rm -rf var/cache/*

Clear by Magento’s code
Clear all frontend caches:
Mage::app()->cleanCache();

Clear cache by tag:
$tags = array("CONFIG");
Mage::app()->cleanCache($tags);


Clear all caches:
Mage::app()->getCacheInstance()->flush();

Hope this will help you !!!! :)

No comments:

Post a Comment