手动输出缓存刷新 [英] Manual outputcache refresh
问题描述
现在,我对一个持续时间设置为365天的动作执行了OutCache.但是,根据某些事件,我想清除缓存,并且清除缓存有多种条件.而且,VaryByParam不是选项.
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.
我该如何实现?
我想我可以这样做,将变量存储在cookie中,例如:RefreshCache = false并在VaryByCustom重写方法中进行检查.如果RefreshCache评估为true,请将其重置为false,将VaryByCustom参数变量增加1.
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.
推荐答案
您可以使用但是,这仅适用于存储在服务器上的OuputCache项目.如果要在客户端上缓存,则此方法将无效.
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.
希望这会有所帮助.
这篇关于手动输出缓存刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!