Jake Ashcraft's WebLog

To busy to blog

Yes, I am still alive, just been busy. Between writing code and playing on the weekends, I have not had the time to blog as much as I would like.

I did run into something interesting though. The documentation for HttpContext.Cache indicates that it returns a Cache object for the current request. So, it was to my understanding that the cache object would be unique to each request. Nope, that isn't the case. So if you did something like:

string someString = “Test“;

System.Web.HttpContext.Current.Cache.Insert(”somekey”, someString);

Then from a seperate machine read the cache like:

string s = (string) System.Web.Current.Cache[”somekey”];

The string value s would in fact be the value “Test“.

Could the MS documentation be wrong? Perhaps I am missing something. I have found several sites that indicate that the HttpContext.Cache is per user and HttpRuntime.Cache is global but this doesn't seem to be accurate.

 

Comments

Me said:

Not sure about the "several sites" you refer to, but all the MS documentation I've seen is clear enough: one instance per application domain and HttpContext.Cache and HttpRuntime.Cache refer to the same object.
# March 3, 2004 6:05 PM

TrackBack said:

^_^,Pretty Good!
# April 10, 2005 4:20 AM

Joe said:

It can be per-user if you use a key which identifies a specific user session. The cache contents are accessible by anything with access to the HttpContext.

# July 13, 2007 12:28 AM

Joe said:

The cache can be used in a per-user fashion if you use a key which identifies the individual user's session. The cache contents are accessible to anything with access to the particular HttpContext.

# July 13, 2007 12:32 AM

Kevin thompson work at home moms. said:

Work at home moms. Site build it work at home moms wahm. Work from home moms. Wahm com the online magazine for work at home moms. Work at home moms resource wahmpros.

# November 5, 2008 8:07 PM

albuterol sulfate said:

Hi there, I hackneyed up your blog via Google while searching sure in return senior gain due to the event that a generosity descend upon and your pass on looks plumb intriguing on me

# August 27, 2010 10:19 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)