I would like to control the cache from the front end when certain calls are made in PracticeUpdate.
For example, when calling /api/GetAllTags from the javascript function GetAllTags, I can see in Fiddler that the return header for cache-control is set to no-cache. Is it possible to modify this in the api?
All you need to do is get Access to the
HttpResponseMessageobject of the request. You can do this inside a controller action by asking theRequestproperty of the controller to create the response for you:Then you can access the
CacheControlobject via theHeaderslike so:You could also make use of an
ActionFilterin this scenario, so caching can be applied to an ApiController Action method via an attribute: