views:

94

answers:

2

Is it possible to have a central cache for an ASP.NET web application that is accessed using multiple domain names? The web application is using a single website and application pool, with multiple domains (host headers) pointing to it.

A bit of background - the application has a lot of data that doesn't change much, and to alleviate database load, I've been storing this in static variables. This has been working without any problems when there is only a single domain. However, with multiple domains, it seems that each domain name being used to access the website has its own copy of this data, so when it's invalidated in one site, the others still retain their own version causing it to never be updated.

I've tried changing this to use HttpRuntime.Cache instead of static variables, but this also exhibits the same problem where each domain being used to access the site seems to be storing its own version of the data.

Is there any way to cache data within an ASP.NET web application that can be shared (and invalidated) across all domains being used to access it?

+1  A: 

Try memcached. You can use the BeIT .Net API.

Memcached runs as a stand-alone service and is meant to facilitate distributed caching. It runs under windows and under Linux.

Manu
Thanks. Was hoping that there was something standard in ASP.NET that could be used to achieve this rather than using another external dependency, but I'll check this out.
Mun
A: 

You could create a table in memory in your database and have all the applications pull from that. It should work essentially the same as your cache does now.

Myles
There is no such thing as "table in memory" for SQL Server. Neither temporary tables nor table variables are guaranteed to reside in memory.
Manu
It is not guaranteed, but you can get very close by allocating enough RAM to the server to accommodate the tempdb which attempts to work from memory if available.
Myles