TimThumb cache directory issue [closed]

Check or add the following two config settings:

define('FILE_CACHE_TIME_BETWEEN_CLEANS', 80000); // 8 seconds = automatic removal of files
define('FILE_CACHE_MAX_FILE_AGE', 20000); // 2 seconds = max. age of file before removed

Update

Maybe using something like this code snippet in your thumb.php or as a stand-alone script executed by cron can take care of the issue. It’ll delete files in your cache directory that are older than 30 seconds.

<?php

$dir="/path/to/cache/";

if ( is_dir( $dir ) ) {
    if ( $handle = opendir( $dir ) ) {
        while ( ( $file = readdir( $handle ) ) !== false ) {
            if ( time() - filemtime( $dir . $file ) >= 1800 ) {
                unlink( $dir . $file );
            }
        }
        closedir( $handle );
    }
}

?>