Caching in Web Services
Inherently, Web services support output caching by use of the CacheDuration property of the WebMethodAttribute class. The CacheDuration WebMethodAttribute is similar to the @OuputCache Duration attribute in that you set its value equal to the number of seconds that a response should remain in the cache. In Listing 16.9 I'll demonstrate how to enable output caching for a WebMethod that returns a DataSet.
Listing 16.19 illustrates how to cache the output of a Web service which returns a DataSet object.
Listing 16.19. Implementing Output Caching in the GetProducts Method
[VisualBasic.NET] 01: <%@ WebService Language="vb" Class="ProductServices" %> 02: 03: imports System.Data 04: imports System.Data.SqlClient 05: imports ... |
Get Programming Data-Driven Web Applications with ASP.NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.