tpower
tpower

Reputation: 56886

Is the ASP.Net Cache shared between different user sessions?

In a page if I do the following:

Cache["key"] = myObject;

Is that cached object available for requests that are for other users?

Upvotes: 11

Views: 8780

Answers (3)

RocketsLee
RocketsLee

Reputation: 51

Cache is good for per AppDomain. The single application like web Applicaiton usually remain in the single AppDomain. But cache can not be shared between something like web app and web service.

Upvotes: 2

Joel Coehoorn
Joel Coehoorn

Reputation: 415840

Yes. The cache is Application level, and all users are in the same application.

If you need a per-user Cache you could use the Session, but that's not quite the same. The cache allows the framework to automatically expire items in a different way from the session. If you want the cache behavior on a per-user basis (not necessarily a good idea) you could build the user's ID into part of your key for the main cache.

Upvotes: 18

AaronS
AaronS

Reputation: 7703

Yes it is available for all users on the same server. However, if you are running a farm, it will only be available to users that are using the server in which the data was added to cache.

Upvotes: 10

Related Questions