Skip to content
Kevin Dockx edited this page Jan 20, 2015 · 6 revisions

What if I need to temporarily override the cache?

To temporarily override the cache for a request (ie to explicitly ask for an uncached response), you should create a request and change the CacheControl header for that request. If you state that NoCache is true, the no-cache header will be added to the request, and the request will get through to the API and not go for possible cached responses in the cache store.

For example:

HttpRequestMessage request = new HttpRequestMessage();
request.Headers.CacheControl = new CacheControlHeaderValue()
{
    NoCache = true                
};
request.Method = HttpMethod.Get;
request.RequestUri = new Uri("youruritoyourresource", UriKind.Relative);
        
HttpResponseMessage response = await client.SendAsync(request);

Clone this wiki locally