1

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!

4 Answers 4

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

0

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

Comments

0

If you want really good performance, I'd suggest Amazon CloudFront. Edge caching will give you better performance than memory caching, and CloudFront runs nginx, which is significantly better than IIS at static files (among other things).

Setting up edge caching is very easy - you log in, and get an domain to use instead of your own for image URLs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.