I have a method that return a complex JSON object. It’s a heavy processing method which i’m trying to store it on cache and leave it there until a modification is done on it’s objects.
[HttpPost]
[OutputCache(Duration=50, Location = OutputCacheLocation.Client, VaryByParam="none", NoStore = false)]
public ActionResult CacheTest()
{
//retrieves data from database
var data = DBContext.GetUserLog();
return Json(new { userLog = data});
}
Setting Location = OutputCacheLocation.Client and VaryByParam = 'none' is not working. If i set Location = OutputCacheLocation.ServerAndClient the response is correctly cached.
Any reasons why OutputCache doesn’t store JSON information on client side?
IIRC POST requests are not cached on the client. This verb is intended to be used when you are modifying state on the server which you don’t seem to be doing. If you are returning some values from the server without modifying state use GET instead.