且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何与QUOT;无效:QUOT; ASP.NET MVC输出缓存的部分?

更新时间:2022-12-08 19:23:33

的一种方法是使用的方法:

One way is to use the method :

HttpResponse.RemoveOutputCacheItem("/Home/About");

在这里描述的另一种方法: http://aspalliance.com/668

我想你可以通过使用你想要的每一个动作的方法级属性实现第二种方法,只是添加到它的字符串重新presenting的关键。这就是,如果我理解你的问题。

I think you could implement the second method by using a method level attribute for every action that you want and just add to it the string representing the key. That's if I understood your question.

编辑:是在asp.net MVC的OutputCache只是一个包装

Yes the asp.net mvc OutputCache is just a wrapper .

如果你使用的VaryByParam =无,那么你只无效/统计 - 那就是如果<&ID1 GT; /<&ID2 GT; 的查询字符串值。这将无效页面的所有版本。

If you're using varyByParam="none" then you just invalidate "/Statistics" - that's if <id1>/<id2> are querystring values. This will invalidate all versions of the page.

我做了一个快速测试,如果您添加的VaryByParam =ID1,然后创建页面的多个版本 - 如果你说无效无效 /统计/ ID1将失效只是该版本。但是,你应该做进一步的检查。

I did a quick test and if you add varyByParam="id1" and then create multiple versions of the page - if you say invalidate invalidate "/Statistics/id1" it will invalidate just that version. But you should do further tests.