Eventually I used a workaround for MVC3 ignoring OutputCache attribute. I used custom action filter for caching:
public class ManualActionCacheAttribute : ActionFilterAttribute
{
public ManualActionCacheAttribute()
{
}
public int Duration { get; set; }
private string cachedKey = null;
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string key = filterContext.HttpContext.Request.Url.PathAndQuery;
this.cachedKey = "CustomResultCache-" + key;
if (filterContext.HttpContext.Cache[this.cachedKey] != null)
{
filterContext.Result = (ActionResult)filterContext.HttpContext.Cache[this.cachedKey];
}
else
{
base.OnActionExecuting(filterContext);
}
}
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
filterContext.HttpContext.Cache.Add(this.cachedKey, filterContext.Result, null, DateTime.Now.AddSeconds(Duration), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null);
base.OnActionExecuted(filterContext);
}
}
Above attribute caches the request based on exact URL path and query for given time, and it works as expected.