Manual outputcache refresh

℡╲_俬逩灬. 提交于 2021-02-11 00:31:11

问题


Right now I have OutCache on an action with duration set to 365 days. However depending on some events I would like to clear the cache and there are multiple conditions for clearing cache. Moreover, VaryByParam is not an option.

How can I achieve this?

I think I can do something like this, store a variable in cookie like: RefreshCache = false and check this in VaryByCustom override method. Incase the RefreshCache evaluates to true, reset it to false, increment VaryByCustom argument variable by 1.

However, I am not sure this is an efficient method to achieve what I want.


回答1:


You can remove the output cache item using HttpResponse.RemoveOutputCacheItem

However, this will only apply to OuputCache items stored on the server. If you're caching on the client then this method will have no affect.

Hope this helps.



来源:https://stackoverflow.com/questions/32311833/manual-outputcache-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!