Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Serious Cache Issues

My server was showing 0% for free space. I hunted down the top 10 directories taking up space and it was Elefant cache directories. I had one site that is a small brochure site grow to over 10GBs in size. This happened across several sites.


  • Can you check what type of files are taking up so much room in your cache?

  • Not sure at the moment. It happened again about 5 days later. Now I'm getting read only file system when I try to clear any cache.

  • That sounds odd, but I would need to know more info to help.

    For reference, I checked an existing site with a handful of custom apps and moderate traffic, and the cache is 12MB total which includes 108 compiled templates, 133 resized images, and 1092 cache files in cache/datastore. Other sites I checked look pretty similar, but nowhere near anything in the GBs.

    Another thing you could try is changing the cache backend in conf/config.php and using something like Memcache or Redis to store cached data, which is often a better solution for cache storage anyway.

  • Well a temporary fix is I'm clearing out the cache directory in sites. Any thoughts on the command that I could run server wide to only clear out the contents of the cache directory and not actually delete the directory?

  • You can clear the cache with this command, run from the folder of the website:

    ./elefant clear-cache

    This removes the following:


    This includes the dot-files found in cache/datastore too. Hope that helps!

  • I was looking a command that I could run server wide on all cache directories without deleting the cache directory. I'm already at 60% fullness from 24% a few days back. I know you can do this with the find command and something like exec rm -rf but I did this previously and removed all cache directories forcing me to have to recreate them individually.

  • Have you tried

    find /path/to/directory -type f -delete

    It works for me.

  • I'm needing something that will delete the contents of every individual cache directory in /var/www server wide. I did a variant of this command once before but it removed the actual cache directory name as well.

  • edited January 2015

    Maybe I did not understand your problem.

    Here in detail what I have done.

    I am in the site root.

    First thing I check what "find" will find.

        user@www.server.tld:/www$ find ./cache  -type f



    Now I run the delete command (in my example I want to preserve .htaccess with "! -name .htaccess")

        user@www.server.tld:/www$ find ./cache ! -name .htaccess  -type f -delete

    Finally I check on which files are left...

        user@www.server.tld:/www$ find ./cache  -type f



    ... and which folders.

        user@www.server.tld:/www$ find ./cache  -type d



    If some files are not deleted could be a permissions matter.

    If you want to do that on many sites folders you can find all folders named "cache" with

        cd /var/www
        find ./ -type d -name cache

    then pass the result to the first "find" command with something like

        find ./ -type d -name cache -print0 | xargs -0 -I{.} find {.} ! -name .htaccess  -type f

    adding "-delete " only if what is found corresponds with what you want to delete.

  • Thanks for your help but here is the easier method I found at least for me. I just run rm -rf /cache/ which I start from inside of /var/www and then it will recursively go through all the folders and remove the contents of cache without removing the folder or harming permissions but of course this would remove a .htaccess file if you have one.

  • Please also consider the performance impact of "rm -rf" in large file/folder structures.

Sign In or Register to comment.