Hi,

the AjaxServerCache attribute can be used to cache the result of an
AjaxMethod call. Add the HttpServerCache attribute to a AjaxMethod
using this code:

  [AjaxMethod]
  [AjaxServerCache(10)]    // seconds
  public DateTime GetCachedServerTime()
  {
    return DateTime.Now;
  }

If you call the GetCachedServerTime method from the client-side
JavaScript you will get 10 seconds the same result, the will not be
invoked. The return value is cached in the global HttpCache, the
result is that everybody who is calling this method will get the same
result. (Note: if you use user specific return values you have to be
careful.)

See the following example which will add a integer i as new argument value:

  [AjaxMethod]
  [AjaxServerCache(10)]
  public DateTime GetCachedServerTime(int i)
  {
    return DateTime.Now;
  }

The cache will now create a new cache object for every "different"
call, I mean for each different arguments used for this method.

  Namespace.Classname.GetCachedServerTime(77, callback);
  Namespace.Classname.GetCachedServerTime(2000, callback);

In the examples above you will get two different cache objects, one
for the 77 and another for the 2000 argument.

Currently the cache object will be destroyed after 10 seconds (the
amount of seconds defined in the AjaxServerCache attribute) of the
first call, there is no sliding time span. I will add this maybe in
the future as an optional argument.

-- 
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.schwarz-interactive.de/
mailto:[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---

Reply via email to