htcacheclean doesn't seem to be cleaning the cache

8,699

Found this response at http://www.gossamer-threads.com/lists/apache/users/404255

Alternative to Apache htcacheclean for mod_disk_cache

We put this in our cron job to run once a day and it's working great.

It deletes all files and directories which haven't been modified in 30 days. We didn't use access time "-atime" to determine which files to delete because for performance reasons, we disabled atime on the file system. A disadvantage of this method is that it doesn't keep cache size under a certain size (htcacheclean does). It does have the advantage of keeping the cached content fresh, is much faster, and seems less resource intensive. We found that our cache size is pretty stable at about 2 to 4 GB (we average 8MM hits/month) so we like this better.

root /usr/bin/find /var/httpd/proxy/* -type f -mtime +30 -exec rm -rf {} \; 

Remember to change the "/var/httpd/proxy/*" directory to point to wherever your cache is.

Share:
8,699

Related videos on Youtube

Will
Author by

Will

Updated on September 18, 2022

Comments

  • Will
    Will over 1 year

    I'm running mod_cache with apache 2 on a fairly high traffic'd site.

    I've set the htcacheclean to run in demon mode every 10 minutes to keep the cache at 4GB. It's currently at 15GB and doesn't seem to be shrinking. When I call htcacheclean manually it hangs for (at time of writing) 40 minutes.

    Some preliminary research turned up this question

    Apache's htcacheclean doesn't scale: How to tame a huge Apache disk_cache?

    said that I should ensure index_dir is on, which it seems to be

    # tune2fs -l /dev/sda3 | grep dir_index​
    Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
    

    Are there other settings that I can turn on / ensure are turned on to help htcacheclean keep up with the cache generation?