adsense

Saturday, July 31, 2010

ASP.NET caching with Web services

In ASP.NET 2.0, the HTTP method of the test page has changed from GET to POST. However, POSTs are not ordinarily cached. Implementing proper caching in your web services can increase scalability and performance. One of the easiest ways to implement caching systems is with the CacheDuration property of the WebMethod attribute.

Eg.
[WebMethod(CacheDuration=100)]


public string GetCacheEntryTime(string Name)

{

StringBuilder sb = new StringBuilder("Hi ");

sb.Append(Name);

sb.Append(", the Cache entry was made at ");

sb.Append(System.DateTime.Now.ToString());



return(sb.ToString());

}