开发者

removing Output cache in Index view on update in asp.net mvc

I'm using output caching for some Index views because they contain a lot of data. I want to keep it specific for every user. because the view can differ depending on the roles.

    [OutputCache(Duration = 3600, VaryByParam = "none", Location = OutputCacheLocation.Client)]
    public ActionResult Index(string schooljaarparam) {
        return View(_db.Lesplaatsens.Where(l => l.Schooljaar.Sch_Schooljaar == schooljaarparam).OrderBy(q => q.Lpl_Gemeente).ThenBy(q => q.Lpl_Instelling).ToList());
    }

Now when someone creates a new item and returns to the Index view. How do I remove the cache of the Index page, so that the newly created item will show up in the list?

I thought this would be a common question but I did not find a solution yet.

I guess you need to use 开发者_JS百科HttpResponse.RemoveOutputCacheItem() but how do I find the route. And where can I see the current cached items in the debugger?


You can't remove the cached item because it isn't there (ie you are not caching it on the server).

When you say Location = OutputCacheLocation.Client, the browser will cache the response and won't even send a new request to your server when the user asks for the same page unless the cache expires or the user specifically asks for the latest version by hitting F5.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜