On my small Apache server I've got a PHP service that will get demands and creates a picture from their store. What I wish to do would be to cache the produced image on my small server (not client's browser) once it had been produced, therefore if the look with specific parameters continues to be produced already and someone demands it my web server will return cached image rather than producing a replacement.

I understand I possibly could store produced images around the server by hand as well as on each request see if they exist, after which run cron tasks to get rid of expired images, however i am searching for more effective way.


You already pointed out the best way. Store it on disk. You may use something similar to memcache, store it in memcache after which have memcache auto-expire the record after some time.

As if you stated, store it around the disk and browse it to the customer. You might have ID.ext and ID.date where ID.date consists of a expire date (in unix time). Then just compare what's in ID.date as to the time() states, if time() is larger than ID.date is, then remove the 2 files and re-create the image.

For the way you are producing the pictures, you may have the ability to use mod_cache to complete your caching for you personally.