0

What is the code for clean or refresh the cache programmatically because I have got lots of snippets but all are not working in Magento 1 enterprise edition.

Does anyone know how to solve it? Thanks in advance.

1
  • Did you resolve you issue? Commented Nov 6, 2019 at 15:56

1 Answer 1

0

To clean cache use this:

Mage::app()->cleanCache();

To flush cache use this:

Mage::app()->getCacheInstance()->flush(); 

You can also use this if you are trying to flush specific cache:

$tags = Mage::app()->getCacheInstance()->cleanType($type);
Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => $type));

Possible types are as follows:

  1. config
  2. layout
  3. block_html
  4. translate
  5. collections
  6. eav
  7. config_api
  8. config_api2
  9. full_page

Reference: How can I programmatically flush Magento's Cache?

Note: You might face problem if you are doing it on frontend. Make sure you do it on admin area.

3
  • will it work on Magento 1 EE? because I have tried but the cache has been not refreshed and the changes are not displayed on frontend.. Commented Nov 5, 2019 at 13:26
  • Yes this should work. However if your changes still refreshed on frontend, then check by manual flushing cache, check if changes still appearing on frontend or not. May be the issue is with something else. Commented Nov 5, 2019 at 18:19
  • But try this code first Commented Nov 5, 2019 at 18:19

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.