.NET: Output caching for WebMethod?
Asked Answered
V

1

10

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?

Voodooism answered 11/8, 2009 at 6:17 Comment(0)
G
16

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.

Giuditta answered 11/8, 2009 at 6:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.