On my Apache server I have a PHP service that gets requests and generates an image from them. What I want to do is to cache the generated image on my server (not client’s browser) once it was generated, so if the image with specific parameters has been generated already and someone requests it my web server will return cached image instead of generating a new one.
I know I could store generated images on the server manually and on each request check if they exist, and then run cron tasks to remove expired images, but I am looking for more efficient way.
Thanks.
You already mentioned the most efficient way. Store it on disk. You could possibly use something like memcache, store it in memcache and then have memcache auto-expire the record after a certain amount of time.