0

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);
        }
hungrycoder
  • 507
  • 2
  • 9
  • 24

1 Answers1

0

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

sternr
  • 6,216
  • 9
  • 39
  • 63
  • You gave me half piece of bread I was expecting of. But how to set the location for this in terms of client server. or is there any default location. as per your url "onRemoveCallback" can we have any other workaround instead of defining method for callback like putting null or something like that? Thnks for the quick reply. – hungrycoder Aug 12 '12 at 21:33