I am trying to implement caching using CacheCow. I have two problems:
In some cases I need to invalidate manually the cache of some resources.
For example, I have a resource that it is called
purchase
, and other that is calledpointMovements
. They are not totally connected, but doing a post inpurchase
, implies some changes inpointMovement
. Cachecow is not detecting these changes because I am not calling the API ofpointmovements
. So when I call the endpoint ofpointmovements
, the values are cached and I cannot get the new values.To solve this, I need to invalidate that manually, how is that possible?
There are some controllers that I don't want to cache. I am trying to use attributes for doing that but it is not working. I am following this article but the attributes are ignored.
How can I specify which controllers to cache?
I came across the same set of problems and found a solution for problem 2 (disable caching regardless of the default settings).
The attributes must be applied together for this to work. You can also control the caching at the action level by providing the same rules to each action.
I've still to figure out the solution for problem 1. but watch this space for updates.
Update I have found a solution to problem 1.
CachingHandler
with your IoC container (in my case it'sIUnityContainer
)ICachingHandler
into your Web API controller.ICachingHandler.InvalidateResource(HttpRequestMessage)
Please see a code example below. The solution has been tested.