问题
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