WebMethodAttribute.CacheDuration プロパティ
アセンブリ: System.Web.Services (system.web.services.dll 内)

Dim instance As WebMethodAttribute Dim value As Integer value = instance.CacheDuration instance.CacheDuration = value
/** @property */ public int get_CacheDuration () /** @property */ public void set_CacheDuration (int value)
応答をキャッシュ内に保持する秒数。既定値は 0 です。応答がキャッシュされていないことを示します。

キャッシングを有効にすると、要求と応答はサーバーのメモリに少なくともキャッシュの存続期間中は保持されるため、要求または応答のデータが大量の場合、または要求が大きく変更される場合は注意が必要です。
ASP.NET 2.0 Web サービス アプリケーションの出力キャッシュに影響を及ぼす可能性がある問題が 2 つあります。
ASP.NET 2.0 では、テスト ページの HTTP メソッドが GET から POST に変更されました。しかし、通常、POST はキャッシュされません。GET を使用するように ASP.NET 2.0 Web サービス アプリケーションのテスト ページを変更すれば、キャッシュは正常に動作します。
また、HTTP では、ユーザー エージェント (ブラウザまたは呼び出し元アプリケーション) で、"Cache-Control" を "no-cache" に設定することによってサーバーのキャッシュ機能をオーバーライドできる必要があることが示されています。このため ASP.NET アプリケーションでは、"no-cache" ヘッダーを見つけた場合に、キャッシュされた結果を無視します。

ServiceUsage XML Web サービス メソッドを呼び出した結果を、キャッシュ内に 60 秒間格納する例を次に示します。その 60 秒間に、XML Web サービス クライアントが ServiceUsage XML Web サービス メソッドを実行すると、常に同じ結果が返されます。
<%@ WebService Language="VB" Class="Counter" %> Imports System.Web.Services Imports System Imports System.Web Public Class Counter Inherits WebService <WebMethod(Description := "Number of times this service has been accessed", _ CacheDuration := 60, _ MessageName := "ServiceUsage")> _ Public Function ServiceUsage() As Integer ' If the XML Web service has not been accessed, initialize it to 1. If Application("MyServiceUsage") Is Nothing Then Application("MyServiceUsage") = 1 Else ' Increment the usage count. Application("MyServiceUsage") = CInt(Application("MyServiceUsage")) + 1 End If ' Return the usage count. Return CInt(Application("MyServiceUsage")) End Function End Class
<%@ WebService Language="C#" Class="Counter" %> using System.Web.Services; using System; using System.Web; public class Counter : WebService { [ WebMethod(Description="Number of times this service has been accessed", CacheDuration=60,MessageName="ServiceUsage") ] public int ServiceUsage() { // If the XML Web service has not been accessed, initialize it to 1. if (Application["MyServiceUsage"] == null) { Application["MyServiceUsage"] = 1; } else { // Increment the usage count. Application["MyServiceUsage"] = ((int) Application["MyServiceUsage"]) + 1; } // Return the usage count. return (int) Application["MyServiceUsage"]; } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からWebMethodAttribute.CacheDuration プロパティを検索する場合は、下記のリンクをクリックしてください。

- WebMethodAttribute.CacheDuration プロパティのページへのリンク