1

How to refresh Magento Cache Management using CMD Prompt?

enter image description here

5 Answers 5

1

I have resolved the issue with my self by the following solution.

Login to your server and run the below command from your magento root directory:

php -r 'require "app/Mage.php"; Mage::app()->getCacheInstance()->flush();'
3
  • I just want clear cache, what i need to put instead of flush();
    – Gem
    Jun 29, 2019 at 10:00
  • 1
    Try this code Mage::app()->cleanCache();
    – Shorabh
    Jul 2, 2019 at 4:44
  • Actually above code working for single website store, but if i try with multi-website store its not working. @Shorabh
    – Gem
    Jul 3, 2019 at 6:20
1

You can use below code:

php -r 'require "app/Mage.php"; Mage::app()->getCacheInstance()->flush();'
8
  • May i know diff bw clear cache vs flush?
    – Aveevan
    Jun 28, 2019 at 11:45
  • 2
    Clear cache only remove enable module cache where flush will remove all cache enable and disabled modules' both @Aveevan Jun 28, 2019 at 11:48
  • I just want clear cache, what i need to put instead of flush();
    – Gem
    Jun 29, 2019 at 10:00
  • rm -rf var/cache/* use this command
    – Ravi Soni
    Jun 29, 2019 at 10:04
  • I don't want remove cache folder bro, i just want clear cache in cache management.
    – Gem
    Jun 29, 2019 at 10:08
0

Remove cache folder:

$rm -rf var/cache/*
4
  • you mean remove the var/cache folder right?
    – Aveevan
    Jun 28, 2019 at 11:42
  • yes!!!!!!!!!!!!
    – krybbio
    Jun 28, 2019 at 11:43
  • I need to refresh snag.gy/BhVw4o.jpg
    – Aveevan
    Jun 28, 2019 at 11:44
  • Once you delete cache folder, cache will be recreated (fresh new).
    – krybbio
    Jun 28, 2019 at 11:46
0

You can clear the Magento 1.9 or below Cache:

Magento keeps its cache in the var/cache/ folder located inside the Magento installation directory. To clear the cache, simply delete everything from the var/cache/ directory and then reload your website in your browser.

You can remove the content of that folder either via File Manager in cPanel, FTP or SSH.

0

I've used this before. I tweaked it slightly so that it runs from shell directory.

http://ka.lpe.sh/2014/06/22/magento-clear-all-caches-from-command-line/

Web root

clearCache.php

echo "Start Cleaning all caches at ... " . date("Y-m-d H:i:s") . "\n\n";
ini_set("display_errors", 1);

require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);
Mage::getConfig()->init();

$types = Mage::app()->getCacheInstance()->getTypes();

try {
    echo "Cleaning data cache... \n";
    flush();
    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... ";
    flush();
    echo Mage::app()->getCacheInstance()->clean() ? "Cache cleared!" : "There is some error!";
    echo "\n\n";
} catch (exception $e) {
    die("[ERROR:" . $e->getMessage() . "]");
}

To run

php -f clearCache.php

Cache isn't necessarily in files so clearing var/cache won't work for everyone.

1
  • This only works in single store mode.
    – HenryHayes
    Sep 20, 2023 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.