I'm trying to get ASP.Net to cache the response of a web service request by setting the CacheDuration
property of the WebMethod
attribute:
[WebMethod(CacheDuration = 60)]
[ScriptMethod(UseHttpGet = true)]
public static List<string> GetNames()
{
return InnerGetNames();
}
The above is a method on an ASP.Net page (I've also tried moving it to its own class, but it didn't seem to make any difference) - I've set UseHttpGet
to true because POST
requests aren't cached, however despite my best efforts it still doesn't seem to be making any difference (a breakpoint placed at the start of the method is always hit).
This is the code I'm using to call the method:
%.ajax({
url: "MyPage.aspx/GetNames",
contentType: "application/json; charset=utf-8",
success: function() {
alert("success");
}
Is there anything that I've missed which might be preventing ASP.Net from caching this method?
Failing that, are there any diagnostic mechanisms I can use to more clearly understand what's going on with the ASP.Net caching?