MVC yi pek bilmem ama VaryByCustom seçeneğinin yardımcı olması lazım.
Kodu şu şekilde düzenlersen:
- [OutputCache(Duration = 6000, VaryByParam="*", VaryByCustom="IslemOzelligi" Location = System.Web.UI.OutputCacheLocation.Server)]
-
- public ActionResult Index()
- {
- return View();
- }
Global.asax dosyana şunu eklersen:
- public override string GetVaryByCustomString(HttpContext context, string arg)
- {
- if (arg == "IslemOzelligi")
- return context.Request.Url.ToString();
-
- return base.GetVaryByCustomString(context, arg);
- }
Duruma göre Cache özelliğinin çalışmasını sağlayabilirsin.
Örnekteki
return context.Request.Url.ToString();satırı örnek olarak yazılmıştır. Burada context i kullanarak istediğin bir özellik, sayfa veya duruma göre bir string göndererek Cache işlemini gruplayabilirsin. Aynı string değerini döndürenler ayrıca arabelleklenir.