cancel
Showing results for 
Search instead for 
Did you mean: 

Cache Types are invalidated: Blocks HTML output

Highlighted

Re: Cache Types are invalidated: Blocks HTML output

Those who say it's NBD, or don't worry about it, don't care. If you are using a minify extension (other extension may have proplems as well), the css and js will revert back to normal.  You must refresh the cache, and run minify css and js everyday.  That's a big deal.

Highlighted

Re: Cache Types are invalidated: Blocks HTML output

I found a solution to make the cache refreshed automatically. This will be done using CRON. Magento do has a default CRON Job to do this but that CRON runs on 02:30 every day. 

 

I use "AOE Scheduler" (link: https://github.com/AOEpeople/Aoe_Scheduler) to configure my CRON Jobs easily. There's no harm in using it. 

 

If you use this extension you can do the following to run the "Cache Refreshing" CRON Job at your suitable time. To change the running time follow the steps:

  1. Go to "System -> Scheduler -> Job Configuration":


  2. Now find "core_clean_cache" from the jobs list:


  3. Click on the row, you will see the edit page. Now go to "Scheduling" section and change the value of "Cron expression" from " 30 2 * * * " to " */15 * * * * ". 
    This will run the CRON at every 15 minutes:

    You can change it to your suitable timing (You can use "crontab-generator.org" to generate the Cron Time Expression for you).

BTW, this solution is tested on Magento CE 1.9.3.2

 

Hope this helps someone. Smiley Happy

Highlighted

Re: Cache Types are invalidated: Blocks HTML output

cache invalidate every time we save product or category or cms page or
block suppose we have updated product on morning 7.00 am then it will
reflect after cron run so better is to make module with and referesh cache
on save product or cms.
Highlighted

Re: Cache Types are invalidated: Blocks HTML output

Config.xml

<global>
          <events>                
                    <catalog_product_edit_action>
                            <observers>
                                    <config>
                                            <type>singleton</type>
                                            <class>config/observer</class>
                                            <method>catalog_product_save_before</method>
                                    </config>
                            </observers>
                    </catalog_product_edit_action>        
            </events>
    </global>
    <adminhtml>
            <events>
              <core_block_abstract_prepare_layout_after>
              </core_block_abstract_prepare_layout_after>
            </events>
    </adminhtml>

 

Observer.php

class Dolphin_Config_Model_Observer
{
    public function catalog_product_save_before($observer)
    {
           try {
                             $allTypes = Mage::app()->useCache();
                             foreach($allTypes as $type => $cache) {
                                  Mage::app()->getCacheInstance()->cleanType($type);
                                  Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => $type));
                             }
                         } catch (Exception $e) {
                             Mage::logException($e->getMessage());
                         }     
   }
   
}

Highlighted

Re: Cache Types are invalidated: Blocks HTML output

I am looking for a fix for this issue also. I have a question, what does the original expression mean - 30 2 * * * "? That it runs every 2 hours? I too wake up every morning to - Cache Types are invalidated: Blocks HTML output. At first I thought it was a bug and submitted it a few years ago. But I have since found out that this is normal behaviour for Magento as I have M2e Pro extension running and this triggers it. I would like to find a way to automatically correct this. Also I get invalidated Cache and Index when I work on products and it would be great if when this happens something could run automatically and flush the Cache and Index upon invalidation. I think I have found 3 solutions but I am not really that technical. I know enough to get me into trouble.

 

https://github.com/tomasinchoo/Inchoo_InvalidatedBlockCacheFix

https://www.magentocommerce.com/magento-connect/block-cache-switch.html

https://github.com/mklooss/Loewenstark_InvalidCache

 

I am running - Magento ver. 1.9.3.4

Highlighted

Re: Cache Types are invalidated: Blocks HTML output

The expression "30 2 * * *" means that the cron job runs at 02:30 every night. 

This answer from stack-exchange explains it.

 

Essentially it is like this: 

first value : minutes

second values: hours

third value : day of month

fourth value: month

fifth value : day of week. 

Highlighted

Re: Cache Types are invalidated: Blocks HTML output

I set up Aoe Scheduler as per Omars recommendation to */15 * * * * for core_clean_cache and I saved a product to generate the message - One or more of the Cache Types are invalidated: Blocks HTML output. Click here to go to Cache Management and refresh cache types.

 

I waited 20 minutes to make sure it ran but the message didn't go away and when I go to Cache Management it still shows it needs to be refreshed. I also logged out and back in and the message is still there. In Aoe Scheduler it shows that it ran though?

Highlighted

Re: Cache Types are invalidated: Blocks HTML output

In app/code/core/Mage/Core/Model/Observer.php

I added one line :

 

    public function cleanCache(Mage_Cron_Model_Schedule $schedule)
    {
        // Line Added to clear block_html
        Mage::app()->getCacheInstance()->cleanType('block_html');

        Mage::app()->getCache()->clean(Zend_Cache::CLEANING_MODE_OLD);
        Mage::dispatchEvent('core_clean_cache');
    }

 

So every day at 2:30, the block_html cache is cleared...

Highlighted

Re: Cache Types are invalidated: Blocks HTML output


gsavary skrev:

I app / code / core / Mage / Core / Model / Observer.php

Jeg tilføjede en linje:

 

    offentlig funktion cleanCache (Mage_Cron_Model_Schedule $ schedule)
    {
        // Linje tilføjet til at fjerne block_html
        Mage :: app () -> getCacheInstance () -> cleanType ('block_html');

        Mage :: app () -> getCache () -> ren (Zend_Cache :: CLEANING_MODE_OLD);
        Mage :: dispatchEvent ( 'core_clean_cache');
    }

 

Så hver dag klokken 2:30 fjernes blok_html cachen ...


This solution worked for me thanks

Highlighted

Re: Cache Types are invalidated: Blocks HTML output

@gsavary  How to writ observer for whatever cache clear requires it will clear automatically, not only block_html. and how to set timing?