I know that when declaring a page method in ASP.NET, I can specify a CacheDuration
like so:
[WebMethod(CacheDuration=60)]
public static void Foo()
{
//TODO Bar
}
But from what I understand, CacheDuration
only supports absolute expiration. I want to have sliding expiration . So that leads me to believe that I need to access the System.Web.Caching.Cache
object somehow. But, since page methods are static, and this is essentially a standalone web service, I'm not sure how to access it statically. The only ways I have seen on Google rely on getting it from the HttpContext
. But, there is no HttpContext
available to me here, right?
Or, do I need to use the System.Runtime.Caching.MemoryCache
to do my own caching?
Much thanks.
you can access
System.Web.HttpContext.Current.Cache
from your page method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.