views:

371

answers:

1

Can I have the return value of a WebMethod outputcached? E.g. if the WebMethod has been called in the last X seconds or minutes, don't actually run the method again--just use the same result as it last served. Or should I roll my own caching internally in the class/WebMethod?

+3  A: 

You can use the CacheDuration parameter of the WebMethod attribute to specify that the output of the request is cached for a given amount of time.

[WebMethod(CacheDuration=60)]

The above code would make your webmethod cache its results for 60 seconds.

womp