phpThumb cache problems

Cabeludo picture Cabeludo · Oct 30, 2009 · Viewed 8k times · Source

I'm using phpThumb - the PHP thumbnail generator.

'phpThumb.config.php':

$PHPTHUMB_CONFIG['cache_maxage'] = 10; 

$PHPTHUMB_CONFIG['cache_maxsize'] = 1000; 

$PHPTHUMB_CONFIG['cache_maxfiles'] = 10;   

but it does nothing... I've got 108 MB in 922 files... and it keeps growing.

Answer

siconet picture siconet · Apr 21, 2010

For me the solution was really simple. After installing phpthumb with the default settings the line $PHPTHUMB_CONFIG['document_root'] = realpath((getenv('DOCUMENT_ROOT') && ereg('^'.preg_quote(realpath(getenv('DOCUMENT_ROOT'))), realpath(__FILE__))) ? getenv('DOCUMENT_ROOT') : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__)))); wasn't uncommeted and all seems to work fine.

BUT: the /tmp directory runs out of space in very short time on a high frequented page.

SOLUTION: It was simple, since phpthumb needs WRITE PERMISSIONS on its $PHPTHUMB_CONFIG['cache_directory'] directory. So be sure that the user who executes your php scripts (usually apache) has the permission to write, otherwise the /tmp directory will be used and filled up with your cached files.

hope this helps!