[英]Invalidate Cache using VaryByCustom
I want to invalidate cache using VaryByCustom attribute. 我想使用VaryByCustom属性使缓存无效。 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)
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.