Jul
15
2009

Magento: Clear the cache with PHP script.

It always take time to get rid of the Magento cache. However cache is needed to execute the request faster. One way of clearing the cache is delete all the directories inside the /var/cache directory. Doing that manually it will take some time if you are connected to the FTP server.
The easiest way of clearing the cache in Magento is here.

<?php

ini_set('max_execution_time', 3600);
ini_set("memory_limit","256M");

$script = "rm -rf var/cache/*";
$results = system($script,$retval);
echo " Cache cleared, RETURN VALUE: $retval\n";

?>

Name the file clearcache.php. Put it in the root directory of the Magento setup & execute in the browser.

Related Posts

About the Author: Jignesh Patel

Jignesh Patel is a geek, an engineer & a web developer, who focus on developing web sites which look great, work great and can still work on older web browsers. Expertise in PHP, MySQL, JS, Magento & Wordpress.

  • http://mtness.net mtness

    ah – what a timesaver.

    Another beautiful scrpt of yours, thank you so much!

    Kind regards, mtness

  • http://www.perfettoprint.com Jordan

    This worked like a charm. Thanks very much for posting.

  • manish patel

    Hello Jignesh patel,

    Your script works fine. thank you so much.

    Regards,
    manish patel

  • Lisa

    Thanks so much! Worked perfectly!

  • Craigcriv

    I get this error

    Parse error: syntax error, unexpected T_STRING in /homepages/41/d293336770/htdocs/magento/varcacheclear.php on line 8

  • Ky

    It’s not the best practice since the command is for linux machines… but can overlook that.

  • Janz

    Thanks, I really need this to make the total summary of cart working.. http://www.webdosh.net/

  • http://modraideja.com Modra Ideja

    great little script, works like a charm :)

blog comments powered by Disqus