asp.netcachingweb-farmdata-caching

Data caching for an ASP.NET website in a web farm environment


I've done some searching and haven't found a specific answer. Anyhow, I was wondering how most medium sized ASP.NET based websites cache data so that they don't always have to database look ups for the same data on different pages when running on a web farm environment. I'm aware that you can use a sql server cache, but to me, that defeats the whole purpose of the cache. If I want to use a dedicated server to share cache (and even possible session data), what do most sites use for this? I've done searching and get a lot of 'guesses' when it comes to implementations, but it's really hard to believe that there isn't some standard way of doing this given that there are so many ASP.NET websites out there.

I am aware of AppFabric that seems like it might do the trick, but only runs on Windows server 2008+ and we're currently using 2003. Also, I've checked out NCache but it seems to be a little pricey.

Has anyone implemented a solution that worked for them? Database lookups can be quite painfully slow when 1000+ users are hitting your site simultaneously.

Thanks in advance!


Solution

  • Might want to take a look at HttpContext.Cache and HttpRuntime.Cache

    You can get your information from the database then create datasets (or dictionaries, or whatever you want) and then store those in cache to be referenced site wide.

    You can even specify how long you want the cache to persist. And when it expires the next request for that data will go to the database and recreate your cache.