This is my controller method. Can anyone explain how I could write outputcache for the following method on the server.
public JsonResult GetCenterByStateCityName(string name, string state, string city, bool sportOnly, bool rvpOnly)
{
var result = GetCenterServiceClient().GetCentersByLocation(name, city, state, sportOnly, rvpOnly).OrderBy(c => c.Name).ToList();
return Json(result);
}
Thank you
Have you looked at the documentation?
http://msdn.microsoft.com/en-us/library/system.web.mvc.outputcacheattribute.aspx
In a nutshell, just set the Attribute on your Action
— UPDATE —
If you’re making a direct Ajax call via jQuery, the OutPutCache could be ignored based on the “cache” parameter – which is set to true by default.
For instance, your parameter would be ignored if you’re doing something like:
Just something to look at as you can cache that call two ways.
Reference: