I'm looking into caching with ASP.NET MVC and I am also in middle of finalizing web-host. I've two questions...
1) Does caching pose issue when done on shared hosting environment since resources are shared and all? This question may sound silly, but I just do not know how caching works behind the scene.
2) Before I implement caching, I want to ask if this approach makes sense. I will cache as much as possible, and invalidate it when needed. However, how does caching work for a list of item that gets updated very frequently, say in a minute or something. For example, the front page of StackOverflow, with so many questions being added every minute, can the front page actually be cached?
EDIT: 3) I would also like to discuss how caching works with paging and all.
I think a minute is a long time if you are servicing 200 requests a second and I would have thought that SO uses asp.net output caching for the front page. They will also most likely use some sort of donut caching aswell to cache the non-user specific portions.
Asp.net MVC uses the standard ASP.NET caching provider unchanged. On a shared host Caching should work correctly however be aware that the host can lock down cache settings if they choose to on a machine level. The Cache provider deals with memory management and will remove items from the cache if memory usage gets too high. I suggest you read the MSDN pages on caching here.
The complication comes from a clustered environment not so much a shared host. On a clustered environment the cache is not distributed to all machines, so each machine has a separate copy of the cache. If this poses a problem then you will need to investigate a distributed caching solution, but in most simple cases this is fine.
With regard to paging, the output caching feature of asp.net allows you to vary-by query string so if you have www.url.com?page=1 this will be stored separately in the cache from www.url.com?page=2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With