tags:

views:

20

answers:

1

I've built an ASP.NET page whose output stream is a dynamically-generated PNG image containing only text on a transparent background.

The text is based upon database IDs contained in the querystring. There will be a limited number of variations.

Which one of the following would be the most efficient means of returning the image to the client?

  1. Store each variation upon the first generation, and thenceforth retrieve this from the drive.
  2. Simply generate the image each time.
  3. Cache the output response based upon the querystring.
A: 

Totally depends on how often this image is going to have to be generated.

If it's a small project I would elect to generate it each time as this would be the simplest solution.

If you are expecting a lot of generations then storing the image each time it's generated and checking for pre generated images would be next, it gets a bit complicated though, all depends on how many unique variations of images you expect to be generated, if it is small, go for it, otherwise you may have to have expiry dates on the images that are not so frequently accessed.

In short, it depends on what the application of this is, and not enough information was given to give a comprehensive answer to your specific solution.

Tom Gullen
There's likely to be a few hundred image variations, and I expect there to be a comparatively high number of requests.The images themselves, from testing, appear to be 30-60KB.
awj
A few hundred * 30-60kb is fairly insignificant storage requirements, you could pre generate them and use them all, or generate them on the fly checking if they don't exist first.
Tom Gullen
Thanks Tom, it's the latter idea that I think I will implement.
awj