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
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.
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.
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
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.
精彩评论