In a page if I do the following:
Cache["key"] = myObject;
Is that cached object available for requests that are for other users?
The ASP.Net Cache is attached to the application domain, so it's shared for all users. If you want to cache something for an individual user, use the Session object. ASP . Net Cache is supposed to be used for things which require extensive server resources but they are shared across users.
The ASP.NET Session object is per user key/value storage, whereas MemoryCache is an application level key/value storage (values are shared among all users).
Cache is stored in web server memory.
To manually cache application data, you can use the MemoryCache class in ASP.NET. ASP.NET also supports output caching, which stores the generated output of pages, controls, and HTTP responses in memory. You can configure output caching declaratively in an ASP.NET Web page or by using settings in the Web.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With