http://www.developer.com/

Back to article

Tip: Improve Web Service Performance, with Caching


November 12, 2003

It's a little-known fact, but you can actually "cache" what a Web service gives out and automatically serve up the same response next time, seriously speeding up popular, processor-intensive services.

How? Simply specify a CacheDuration parameter in the WebMethod attribute, like this:

    <WebMethod(CacheDuration:=60)> _
    Public Function GetWeather() As String
        ' ... complicated code ...
    End Function

Here, the Web server will cache and serve up the same results for GetWeather 60 seconds after the last query. You can see this cute tip in action by returning the time from a function. See what happens?

About the Author

Karl Moore (MCSD, MVP) is an experience author living in Yorkshire, England. He is author of numerous technology books, including the new Ultimate VB .NET and ASP.NET Code Book (ISBN 1-59059-106-2, $49.99), plus regularly features at industry conferences and on BBC radio. Moore also runs his own creative consultancy, White Cliff Computing Ltd. Visit his official Web site at www.karlmoore.com.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date