When I use outputcaching on an action method it is cached by full url, what i would like to do is cache the page but ignore some parts of the url.
Custom route defined in Global.asax:
routes.MapRoute(
"Template",
"Report/{reportid}/{reportname}/Template/{templateid}/{action}",
new { controller = "Template", action = "Index" }
);
My template controller
public class TemplateController : Controller
{
[OutputCache(Duration=60*60*2)]
public ActionResult Index(Template template)
{
/* some code */
}
}
For example when I go to the following URL's:
http://mywebsite.com/Report/789/cacheme/Template/5
-> cached for 2 hours based on the url
http://mywebsite.com/Report/777/anothercacheme/Template/5
-> also gets cached for 2 hours based on that url
What I would like is that the OutputCache ignores the reportname and reportid values so when I go to the above url's it returns the same cached version. Is this possible with the OutputCache attribute or will I have to write my custom OutputCache FilterAttribute?
VaryByParam
for templateid only. Apart from that custom filter attribute will be the way to go! – Collodion