I am using the rmagick gem for generating dynamic images from a controller. The controller takes an id as a param, does a look up on a model, writes text over an existing image, and outputs it.
I have run some benchmarks comparing generating it for every request versus writing to disk and using send_data
to output it if it already exists. I haven't noticed much of a difference in requests/second between these two methods.
Is there a best practice for caching the image or writing it to disk instead of generating it dynamically for every request? Once generated, these images would remain mostly static but I would also like the option to re-generate it after a certain time interval.