I want to invalidate cache using VaryByCustom attribute. Following code is being used for cache setup.
public override string GetVaryByCustomString(HttpContext context, string arg)
{
if (!string.IsNullOrWhiteSpace(arg))
{
if (context.User.Identity.Name != null)
{
return context.User.Identity.Name;
}
}
return base.GetVaryByCustomString(context, arg);
}
Are you using it like this:
Make sure you decorate your action with attribute:
[OutputCache(Duration = 3600, VaryByParam = "*", Location = OutputCacheLocation.Server, VaryByCustom =
"YourStringThatIsArgParamInYourGlobalAsaxMethod")]
public ActionResult MyActionOnTheController(string myParam)
{
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.