Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does HttpRuntime.Cache stores data?

Tags:

c#

asp.net

I am trying to implement a web application with Caching features.The reason I need caching is for is that we have an application which lets users access online courses. Now, Once the user logs in I validate him against our database. Once validated I want to store the user ID and course ID in cache for 20 mins so that if he requests it again I can retrieve values from cache foe both user id and course ID and if valid provide him access For some reasons I can't use Session variables in this application so they are not an option.

Now, the caching code in my application is inside a HTTP Handler(.ashx file). Now I tried calling the cache object like you do for a aspx page but I could not, probably because it's a handler and not a webpage. So,

Cache.Insert("Id", 123); 

will not work in Handler. So then I tried HTTPRuntime.cache. But after doing some research I found out the HTTPRuntime.cache is common to the whole application. I don't completely understand "Whole application". Does it mean that it is shared by all the users on different computers accessing our applications? or does it mean it's shared by all the users on one computer accessing our application. Because if it is the latter I am OK with it. So is HTTPRuntime.cache a good way to cache data for one browser(or one computer) or is there a different and better way to implement Browser caching to store data?

like image 486
Abhi.Net Avatar asked Jun 04 '12 05:06

Abhi.Net


1 Answers

Cache is stored in web server memory.

You should understand the differences between Viewstate, Cache and Session

like image 194
Nikhil D Avatar answered Sep 30 '22 01:09

Nikhil D