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.

Comments

  • 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:

    cache/*.php
    cache/datastore/*
    cache/navigation.json
    

    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
    

    result:

        ./cache/user-sidebar.php
        ./cache/thumbs/07b59aa26f5f6e8c4f00ab863e3e12fa-cover-100x75.jpg
        ./cache/thumbs/3a1c9dd10c2beca769ff38ae0939cf9b-cover-100x75.jpg
        ./cache/thumbs/326006aecf016abfefabe98236549061-cover-100x75.jpg
        ./cache/thumbs/1d5501b09ae92a91d47bb24c38e3e5f4-cover-100x75.jpg
        ./cache/admin.php
        ./cache/datastore/e0f7e47ddbc8fe65208a2669c620192e
        ./cache/datastore/da9da02d28d11c23e2c389e0e4fd4e91
        ./cache/datastore/c5aa0f459d771d5d0564e3498fa6aa0b
        ./cache/datastore/39e5647d78c291c7681a7f7b8f544e22
        ./cache/datastore/d1951d69ee1e73e5ea18eda6c77b9fd1
        ./cache/.htaccess
        ./cache/admin-index.php
        ./cache/user-recover.php
        ./cache/default.php
        ./cache/user-signup.php
        ./cache/filemanager-slideshow.php
        ./cache/user-login.php
    

    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
    

    result:

        ./cache/.htaccess
    

    ... and which folders.

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

    result:

        ./cache
        ./cache/thumbs
        ./cache/datastore
    

    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 domain-name.com 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.