After going through phpThumb caching hell (lots of cached files in a dir, server freezing etc) I came up with this lib. When a user requests some content (say a resized image) an apache errordocument calls the lib which generates the content. The second time the same content get requested, apache will serve it directly without involving php or anything!
Copy this package into /dynamic directory of your website. write a in the browser http://[site.com]/dynamic/320x200/yourimagefolder/yourimagesubfolder/image.jpg after that... refresh again.