我有这样的动作:
[OutputCache(Duration = 3600,Location = OutputCacheLocation.ServerAndClient,varyByParam = "page;categor;searchString")] public virtual async Task<ActionResult> Index(int? category,int page = 1,string searchString = null)
此操作可以具有多个缓存结果.到目前为止它的罚款.但是当我发布新内容时,我想删除所有这些多个缓存结果.
我知道我可以在foreach中使用RemoveOutputCacheItem和url列表.
var urls = new List<string>(); foreach (var url in urls) { HttpResponse.RemoveOutputCacheItem(url); }
解决方法
Is there a better way to remove all those cache at once
不是我知道的.但是您可以删除特定控制器操作方法的缓存项,如下所示(假设您的控制器名称为controller1).从Clearing the ASP.Net MVC Cache采取的想法
HttpResponse.RemoveOutputCacheItem(Url.Action("Index","controller1",new { category = 1234 }));
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。