Hugo Alves
Hugo Alves

Reputation: 1555

Does RestSharp have cache

I have a simple question, that I can't find a straight answer:

Does RestSharp cache request made? If it does, how much time does the cache last and how can i change it? If it doesn't, how can I add cache to RestSharp?

I'm using it in an Asp.net MVC app deployed to Azure web application.

Thanks for any help.

Upvotes: 3

Views: 7009

Answers (2)

Kaven Wu
Kaven Wu

Reputation: 51

https://github.com/restsharp/RestSharp/issues/401

var client = new RestClient("http://example.com");
client.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Revalidate);

Upvotes: 4

CodeCaster
CodeCaster

Reputation: 151604

RestSharp doesn't cache by itself, but under the hood the framework classes it uses do, through WinInet.

You can bypass this cache with conditional requests, or by adding a cache buster to the query string.

This all is influenced by the Cache Policy, see MSDN: Cache Policy.

See also How to clear the cache of HttpWebRequest, WP7 - Prevent RestSharp from caching, Refreshing in RestSharp for Windows Phone and so on.

Upvotes: 4

Related Questions