Reputation: 2168
I am attempting to cache the output of a WebMethod in my WebService. The Method I am trying to cache returns Data that will likely only change once every few months at most, so I would like to cache that output to cut down on load time. I have been looking at the WebMethod CacheDuration property, but caching the output will not help me at all if CacheDuration is only Session level. Does anyone know whether CacheDuration will work on the Application Level?
Upvotes: 0
Views: 1798
Reputation: 70379
There is no explicit answer to that BUT on MSDN (see http://msdn.microsoft.com/en-us/library/system.web.services.webmethodattribute.cacheduration%28v=VS.100%29.aspx and http://msdn.microsoft.com/en-us/library/byxd99hx%28v=VS.90%29.aspx) it indictates that caching depends on "unique parameter sets" and not on the session... so I assume it is application level - with the samples provided at those links you could test that easily...
Another option worth exploring regarding caching is to explicitly use the Cache
class - this gives full control over all aspects of caching although is less "transparent" than the method you describe... for example you can set duration how long the cached item stays "valid", you can provide a callback which is called when an item is about to be discarded etc.
Upvotes: 2
Reputation: 12589
I can't find a reference that definitively says it's one or the other, but I would assume it's applied at the Application level if only because applying it at the Session level doesn't make sense e.g. it wouldn't help your scalability.
Upvotes: 0