I'm trying to outputcache a action method in asp.net mvc. The method returns json and is called by jquery $.ajax, data in the call is json. How can I make the outputcache vary by the json sent to the method?
Asked
Active
Viewed 1,702 times
1 Answers
3
You can use OutputCache and VaryByParam="*"
[HttpPost]
[OutputCache(VaryByParam="*",Duration=10)]
public ActionResult TestOutputCache(Entry entry)
{
return Content(entry.Description + " " + DateTime.Now,"text/plain");
}
This will add any POST buffer that's different and cache it individually.
Unless you know you'll have many recurring values this is not a great idea though as your cache may get large with many values quickly.

Rick Strahl
- 17,302
- 14
- 89
- 134