1

I'm making web application in asp.net mvc 2 which is some kind of photogallery. I will have to dynamically make and display thumbnails (not save on disk) and I would like to keep these thumbnails in cache. Is it possible to do it in mvc2 and how? Or is it maybe better to save thumbnails to disk (although I would like to avoid this because there should be option for dynamically set size of thumbnails)

Thanks,
Ile

2 Answers 2

3

If you just need some fixed sizes (3 or 4) then it would be better to generate files and save them on the disk.

If you really need dynamic size (as parameter) then the easiest solution will be using ASP .Net Output Cache. There is OutputCacheAttribute (special action filter) for integrating it into ASP .Net MVC projects.

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

1 Comment

then it looks like I will need to save them to disk after all. Thanks :)
2

Well static resources such as images are normally cached by the browser so that's probably the first level of cache you could be using. Because you are generating dynamic thumbnails you could still set proper caching headers so that those thumbnails are cached by the user. If you want a shared cache for all your users then you will need to store it on the server. If you don't want to save the thumbnails on disk you could always use the built-in Cache object but that's going into memory and you might quickly start running out of memory. And when this happens you could off-load your cache using providers like memcached or simply save them on disk.

1 Comment

well, the idea is to cache thumbnails on server because I'm afraid it would take too long to regenerate these thumbnails every time the page is loaded. Thanks for comment

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.