I cache everything that is possible on the ASP.NET MVC website and it works fine. Now I have created an API in which calls go to Controller actions. ( http://mysite.com/topics/latest.json )
The API is able to return results in different formats (json, xml, rss). The data to return is loaded into Action:
[ResponseFilter] public class HotTopicsController : Controller { [OutputCache(Duration = 60, VaryByParam = "none")] public ActionResult Latest() { ViewData.Model = MyService.GetRepository().ApiViewData().Topics().Latest(); return View(); } }
ResponseFilter is responsible for returning data in the correct format (json, rss, xml).
Since it is not possible to make JSON requests from another domain (I want the API to be accessible to others), I have to use JSONP. JSONP requires a callback set.
Need to set callback name in response I cannot perform default caching with OutputCache.
I know articles about donut caching (Phil Haacked: http://haacked.com/archive/2008/11/05/donut-caching-in-asp.net-mvc.aspx and others). But they all handle this topic in Views. Since I just installed ViewData.Model and have no idea, I cannot solve the problem this way.
What are your suggestions for solving this problem?
source share