问题
I have the following caching attribute on my controller method:
[CacheOutput(ClientTimeSpan = 14400, ServerTimeSpan = 14400)]
I am attempting to clear the cache. However, after running this line of code:
//clear cache
cache.RemoveStartsWith(Configuration.CacheOutputConfiguration().MakeBaseCachekey("BeamsController", "Get"));
I am still getting a 304 not-modified response without the controller method being invoked.
I am using this library https://github.com/filipw/AspNetWebApi-OutputCache
回答1:
[InvalidateCacheOutput("Get", typeof(BeamsController))]
seems to work, instead of 'manual invalidation' (RemoveStartsWith
), above.
In fact, after reading the source code of the attribute, it appears that the documentation is wrong and it should be:
cache.RemoveStartsWith(Configuration.CacheOutputConfiguration().MakeBaseCachekey("Beams", "Get"));
which works as expected, calling the method.
来源:https://stackoverflow.com/questions/28325060/webapi-outputcache-cache-invalidation