1

I'm currently developing an image viewer using asp.net MVC. The image viewer itself works as a charme, but I'm not happy with the caching.

To explain: I'm using the GeneratedImage (http://aspnet.codeplex.com/releases/view/16449) in order to produce the thumbs, but the Server Side Caching is only limited to 5 Minutes and can't be changed as far as I know.

So my question is, if there's another solution for caching the generated thumbs or the complete site (inlcuding the generated images) - if that is possible.

Thx in advance

BitKFu
  • 3,649
  • 3
  • 28
  • 43
  • so you dont put the thumbs on the harddrive but generate them every time on the fly? and try to 'save' then with caching? – Stefanvds Sep 14 '10 at 06:56
  • Currently I'm producing the thumbs on the fly. But they are transient products. So I thought it would be a good idea to have some caching in place, that can deliver the thumbs faster than I create it. Also 'saving' it to disk would be a caching in my opinion. GeneratedImage does this - it stores the images to disk, but only with a limitation of 5 Minutes, which I think is very too short. That's why I was looking for a better component in order to have an intelligent caching mechanism in place. Storing all thumbs to disk is no option due to the amount of space that might be used. – BitKFu Sep 14 '10 at 07:23

4 Answers4

1

Check out the Image Resizing Module from Nathanael Jones. It does thumbnailing and configurable caching all in one easy module. It's not free but it's really easy to use and set up and it works really well.

zulkamal
  • 578
  • 1
  • 4
  • 17
  • As this is only a project for learning and better understanding ASP.NET MVC, I don't want to spent money for it ;) – BitKFu Sep 07 '10 at 07:30
  • Since its the only component that all can do, what I think of, I reward the 50 points to you. – BitKFu Sep 15 '10 at 15:19
1

I am building some similar application, and I don't think that "caching" the generated image (especially if they won't be re-created anytime soon) is a good idea. The solution we adopted is to upload the image directly to Amazon S3, and use that as a permanent cache.

This way, all you need to store is a new URL, and you get a Cloudfront system for free, making your images load much much faster. In the worst case scenario, if you have to re-generate an image, you can always delete and re-create the object on S3, since it's not an extremely expensive process.

ninjagod
  • 11
  • 2
  • That idea sounds interessting ... So could you post the code, how to upload the image to Amazon S3? At the moment I have no idea how to make it. – BitKFu Sep 12 '10 at 17:18
  • @BiKFu looking for something so specific will get it to you a lot faster than having someone who posted an answer go through their files and modify it to make it safe to share ... btw, +1 to this answer – eglasius Sep 14 '10 at 19:36
0

Yes, your right. The caching implementation lacks.

You can enable client and server caching. But you can only set the client cache timeout. The server cache timeout is hidden in private fields, classes and constructors.

The ImageHandler has an private field Implementation of type ImageHandlerInternal. This one does the whole job. It uses an implementation of IImageStore what does the whole server side caching. IImageStore is an internal interface of Microsoft.Web. No way to implement your own imagestore. The handler is an internal class. No way to extend this by your own.

It's a pity that this is totaly hidden for users. Look for another sample, doing image transformations! There are a lot of samples out there. http://www.google.com/search?q=image+thumbnail+c%23

EDIT:

There are some questions about output caching of an ashx handler.
Following uses client side caching How to use output caching on .ashx handler
Serverside caching Caching http handler .ashx output

Community
  • 1
  • 1
Christian13467
  • 5,324
  • 31
  • 34
  • The problem is not the physical creation of the thumbnails. It's only the caching. Are there any other ImageHandlers like the GeneratedImage, or maybe it's better to cache the complete site? Are there any solutions for it? Thats mainly what I'm looking for. – BitKFu Sep 07 '10 at 07:41
0

I think, you can save the urls'(local or cloud) of the images to your data store and when the application is opened, in the UI layout, display those many number of tags with the src set to the saved source. So that the page loading will be faster since the image loading will take place only after the document loaded/ready, because the browser can make asynchronous requests to those different urls, symultaneously.

Siva Gopal
  • 3,474
  • 1
  • 25
  • 22