Reputation: 3036
In my controller action before the response return line I have the following code:
HttpContext.Response.Cache.SetCacheability(HttpCacheability.Public);
HttpContext.Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
HttpContext.Response.Cache.SetAllowResponseInBrowserHistory(true);
When i call this action like "/Controller/Action" then the result is cached well in browser. But when I try to add any parameter like here "/Controller/Action?v=1" then it's never cached more (tried in fiddler). What am I doing wrong?
Upvotes: 0
Views: 42
Reputation: 4310
Use the OutputCache attribute on your controller action. You can change where the cache can happen with the Location parameter.
[OutputCache(Duration = 6000, VaryByParam = "v", Location = OutputCacheLocation.Client)]
public ActionResult MyAction(int? v) {
return View();
}
Upvotes: 1