In the company I work for, we have a web application developed with ASP.NET MVC2 and hosted on IIS7.
In a specific action, we return a JsonResult object holding an array. This array is updated daily; so any request coming in the same day will end up with the same response.
public ActionResult SomeAction(int id)
{
// Some calculations
return Json(resultArray, JsonRequestBehavior.AllowGet);
}
Since the operation is costly, we wanted to improve performance with browser caching and so.
I added a cache header, so we are telling user browser to cache the result till the next update of the database.
Besides that, I want to add a "Last-Modified" header, so browser will ask for if the source is modified after the specified date.
What is the way to accomplish that? I want to check if DB is modified after the date browser asked (Last-Modified header) and if not modified, I want to return 304 just IIS automatically does for static files (images, css and js files etc)