HttpRuntime.Cache does caching on client/server side

1.6k views Asked by At

Does the HttpRuntime.Cache which I declared in the global.asax file in asp.net web application does caching on client side or server side?

HttpRuntime.Cache["Key"]

Also is there any chance that we can set the sliding expiration for this piece of code?

Thanks in Advance.

Edit: I assume this will be the possible solution after lot of thinking.

Put a basePage class for the entire asp.net web application in which all the system.web.ui.page will inherit from this class.

and the following code

protected override void OnInit(EventArgs e)
        {
            OutputCacheParameters aa = new OutputCacheParameters();
            aa.Location = OutputCacheLocation.Client;<-- I am not sure whether this will work and gets added to the pages correctly or not.Any Ideas on these two lines of code.
            base.OnInit(e);
            Cache.Add("State", "", null, DateTime.Now.AddMinutes(20), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
            Cache.Add("StatesGlobal", "", null, Cache.NoAbsoluteExpiration, new TimeSpan(1,0,0,0,0), CacheItemPriority.High, null);
        }
1

There are 1 answers

1
sternr On

On the server.

If you want to set the expiration policy for the item, you should use the Cache.Add API:

http://msdn.microsoft.com/en-us/library/system.web.caching.cache.add.aspx