I was just looking at the cache cleanup code the other day and wondering if it worked at all or if I was missing something. In core/model/phpthumb/phpthumb.class.php starting on line 658 there's this:
$AllFilesInCacheDirectory = phpthumb_functions::GetAllFilesInSubfolders($this->config_cache_directory);
foreach ($AllFilesInCacheDirectory as $fullfilename) {
if (preg_match('/^phpThumb\_cache\_/i', basename($fullfilename)) && file_exists($fullfilename)) { ...
Because phpthumbof's cache isn't named phpThumb_cache, I think phpThumb's CleanUpCacheDirectory method doesn't do anything but waste time listing all the files in the cache directory. The cache cleanup gets run every time you call phpthumbof, so with a large number of files in the cache directory this'll definitely start affecting performance.
Sometime soon I'm going to look into this more and fix it if it's indeed not working.
In the meantime there are a few easy–if hacky–fixes:
- Edit core/components/phpthumbof/model/phpthumbof/phpthumbofclass.php and comment out $this->cleanCache(); on line 348
- -or- under Systems Settings / core > phpThumb set phpThumb Max Cache Age, Files, and Size to 0
Both of these turn off cache cleanup. The first one is slightly faster.
One of the reasons you have so many files in your cache may be because of the way phpthumbof names cache files. If you're using the same image with the same parameters on multiple pages, it'll create separate images for each instance. See this pull request for some more information and a fix:
https://github.com/splittingred/phpThumbOf/pull/49