views:

115

answers:

4

Hi guys,

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

+2  A: 

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
As this is only a project for learning and better understanding ASP.NET MVC, I don't want to spent money for it ;)
BitKFu
Since its the only component that all can do, what I think of, I reward the 50 points to you.
BitKFu
A: 

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 http://stackoverflow.com/questions/1109768/how-to-use-output-caching-on-ashx-handler
Serverside caching http://stackoverflow.com/questions/1669975/caching-http-handler-ashx-output

Christian13467
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
+1  A: 

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
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
@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
A: 

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