can someone explain to me how to implement JsonResult action JsonResult in MVC 5 application? I want to use caching of some ajax certified actions using the [OutputCache()] attribute. Some of these actions return an ActionResult with html -content, some JsonResult with serialized lists of pairs {Id, Title} , which I am going to use to create drop-down lists.
My goal is to reduce the number of database queries (when creating ViewModels) and server requests (when using ajax calls for it).
So my code looks like snippets below:
[OutputCache(Duration=60*60*24)] public async Task<ActionResult> SearchCaseOrgDialog(){ //extract data return html page return View(); } [OutputCache(Duration=60*60*24)] public async Task<JsonResult> AjaxOrgDepartments(){ //query database, serialize data, return json var result = await ctx.OrgDepartments .Select(d => new { Id = d.Id, Title = d.Title } ) .ToListAsync(); return Json(result, JsonRequestBehavior.AllowGet); }
When I look at the FireFox toolbar, I see the following image for html -content: 
Here, Firefox uses the client-side cached version of the ajax -requested page.
But the situation is different from json -content: 
It does not cache the contents and, apparently, transfers data from the server (server cache).
In both cases, the response headers look the same:
Cache-Control:"public, max-age=86400, s-maxage=0"
Content is requested using similar ajax collections, e.g.
$.get(url, null, function(data){
So how can I cache json-content? how to do it right and why does the default approach not work?