4

You can obviously manually flush the catalog images cache by going to Cache management and clicking on "Flush Catalog Images Cache". My question is can this be set as a scheduled task? If so, what would the code be to create this and what file would it be inserted into?

The below extension looks like it will do what I'm after and a bit more, so will possibly just go with that unless there are any suggestions of a better way to do?

http://www.magentocommerce.com/magento-connect/cron-cache-cleaner-3782.html

2 Answers 2

2

Try using Fabrizio Branca's automatic cache cleaning extension. You can clear any of your cache's using a cron expression that you can set for each of the caches. Just make life simpler ;)

http://www.fabrizio-branca.de/magento-automatic-cache-cleaner.html

6
  • Glad to help out.
    – Shatir
    Oct 29, 2013 at 12:12
  • Hi @Shatir I've noticed that for whatever reason, this extension isn't actually clearing our cache. I fear there is nothing wrong with the extension itself, all configured/installed correctly etc. But that the issue lies with the existing setup of our site. As my manual efforts to add cron expressions in previously didn't run either. We can manually clear cache fine, but any efforts to clear with cron jobs are failing :( Any ideas how to debug at all? I have no clue as we get no errors or warnings in log files etc.... :(
    – MagentoMac
    Oct 31, 2013 at 8:17
  • You need to first confirm if your cron is setup properly. Make sure you've added an expression to run Magento's cron in your Cpanel (magentotutorials.co.uk/magento-cron-setup-in-cpanel). Also to check if your cron is executing properly you could use the AOE scheduler (It is an extremely useful tool for scheduling and running cron tasks or just having a view of them) magentocommerce.com/magento-connect/aoe-scheduler.html
    – Shatir
    Oct 31, 2013 at 12:39
  • Note: If cron.php located in your root Magento folder isn't added as a cron expression in your Cpanel, none of your cron tasks would run (I've provided a link in my previous comment which shows how to add it in Cpanel).
    – Shatir
    Oct 31, 2013 at 12:45
  • Hi @Shatir cron is running fine, we have 20+ cron jobs we run regularly, and all others are fine. I think it might be the cron expressions listed in the System settings area. I've modified these slightly. Changed to run once a day at set time, e.g. 0 1 * * * and 0 2 * * * etc staggered to each cache component runs at different times. Will see if that works tonight.
    – MagentoMac
    Nov 1, 2013 at 1:01
4

Essentially this will do it for you

Mage :: getModel( 'catalog/product_image' ) -> clearCache();

so you can create a php file including this which you add to your cron jobs (see - https://stackoverflow.com/questions/5460165/how-to-clean-magento-cache - for more info). Alternatively if what you need to delete is limited to product images for example you can delete the contents of the appropriate cache folder (i.e. media/catalog/product/cache). Again you can cron this job as a batch file or use php exec.

Your Answer

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

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