Auto clear cache so my Digital Ocean server does n... - Magento Forums
cancel
Showing results for 
Search instead for 
Did you mean: 

Auto clear cache so my Digital Ocean server does not crash

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Auto clear cache so my Digital Ocean server does not crash

The cache in magento , over time , uses up more and more data until the server is crashed.

 

How do I automatically have magento clear the cache so my server does not crash AGAIN :

 

In /admin > cache management > auto cache these 3 :

 

Additional Cache Management
Flush Catalog Images Cache Pregenerated product images files.
Flush Swatch Images Cache Pregenerated configurable swatches image files.
Flush JavaScript/CSS Cache Themes JavaScript and CSS files combined to one file.

2 REPLIES 2

Re: Auto clear cache so my Digital Ocean server does not crash

Hi @pablo_williams,

 

Are you using something different to the base file cache of Magento?

Can you check if the var/cache directory is the cause of the problem? (checking the size of that directory over time)

Re: Auto clear cache so my Digital Ocean server does not crash

Hello @pablo_williams,

 

If in your Magento system, Magento cron jobs are working properly then you define a cronjob which fire on midnight and clear cache.


File1: create config.xml at app/code/community/Vendor/Cleancache/etc/

<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
    <Vendor_Cleancache>
        <version>1.0.0</version>
    </Vendor_Cleancache>
</modules>
    <global>
        <models>
            <cleancache>
                <class>Vendor_Cleancache_Model</class>
            </cleancache>
        </models>
    </global>
    <crontab>
        <jobs>
            <clean_cache_midnight><!-- identifier -->
                 <schedule>
                     <cron_expr>0 0 * * *</cron_expr> <!-- running cronjob on midnight -->
                 </schedule>
                <run>
                    <model>cleancache/Fire::fireCacheonMidnight</model>
                </run>
            </clean_cache_midnight>
        </jobs>
    </crontab>
</config>

File2: create Fire.php at app/code/community/Vendor/Cleancache/Model/

<?php
class Vendor_Cleancache_Model_Fire
{
    public function fireCacheonMidnight(){

     /**
     * Flush all magento cache
     */
     Mage::app()->cleanCache();
    }
}

File3: module config file Vendor_Cleancache.xml at app/etc/modules/

<?xml version="1.0" encoding="utf-8"?>
<config>
    <modules>
        <Vendor_Cleancache>
            <active>true</active>
            <codePool>community</codePool>
        </Vendor_Cleancache>
    </modules>
</config>

 

--
If my answer is useful, please Accept as Solution & give Kudos