The ASP.NET Cache object in a Web Gardening scenario with IIS5 or IIS6
Remember that "Web Gardening" is like having a tiny Web Farm on a multi-proc box. Each processor gets an ASP.NET Worker Process with affinity (that means the process "sticks") to that processor.
But what happens if you use the Cache object? Well, each AppDomain gets a Cache object, and each ASP.NET Worker Process has one AppDomain per Web Site, and each processor gets one WP, so...if you have four processors, the Cache object will exist four times.
That means, ASP.NET Cache state is NOT shared amongst processors in a single-box multi-proc system.
Make sure you grok this if you ever find yourself working on a single box web site with multiple procs and web gardening on. If you've:
- coded your site to assume that the cache will fill once and only once per machine
- used physical files as CacheDependancies to key off the cache
- assumed that any one user will magically return to the same process on the same machine on subsequent requests
then things may well behave differently than you thinkin a web gardening scenario.