views:

648

answers:

3

I am working on a web application with many images, using ASP.NET MVC. I want to be able to cache the images in memory to improve the performance, but I would like to hear what is the best way to do this.

1) The images are accessible from URL, like http://www.site.com/album/1.jpg. How are the images stored in memory? Are they going to be in a form of memory stream?

2) How to access the image from memory and send to the web pagee? Now the web pages will use the image URL to directly embed the image in a tag.

Thanks!

+2  A: 

Wont the webserver and downstream caches be handling this for static resources anyway? Not sure there's many performance gains to be had, but knowing nothing of the app or setup I could be wrong.

To implement I'd setup a page that took an image filename and served it either from disk or from the asp.net in memory cache.

Steven Robbins
A: 

Thanks for the response. I think I was thinking the wrong direction. I just found out Flickr is using Squid to cache images.

ycseattle
+1  A: 

If the images are just static files on disk, then Beepcake is right that IIS will already be caching frequently used images and serving them from memory. Using separate caching servers shouldn't be any quicker than IIS serving an image from memory - it's got more to do with scalability. Once you have a large server farm, it means you have a group of servers just dealing with your code and a group of servers just dealing with static images. Also, if you have too much content for one server to cache it all then you you can route requests so that each of your ten servers caches a different 10% of your content. This should be much better than just having each server cache the same most-used 10% of the content.

stevemegson