aliostad / CacheCow

An implementation of HTTP Caching in .NET Core and 4.5.2+ for both the client and the server
MIT License
848 stars 171 forks source link

Support for HttpClientFactory #228

Closed jkonecki closed 5 years ago

jkonecki commented 5 years ago

I would like for CacheCow to support HttpClientFactory instead of creating new instances of HttpClient itself.

I'm happy to implement the changes given design guidelines.

aliostad commented 5 years ago

Hi Jakub,

Essentially CacheCow's client story is done as a delegating handler which gets added to an HttpClient. So the application is responsible for creating the HttpClient as such would be involved in passing a singleton CachingHandler whenever client is created, i.e. CacheCow is oblivious to the process - hence no work required.

CacheCow provides some helpers in the ClientExtensions to build the HttpClient. I guess they just need to be avoided - I might review in the future to remove them.

Does it help?

jkonecki commented 5 years ago

Yes - here is an example of what I'm doing:

https://github.com/damianh/ProxyKit/blob/master/src/Recipes/11_CachingWithCacheCow.cs

Works perfectly as I don't use ClientExtensions to instantiate HttpClient myself.

On Mon, 28 Jan 2019, 22:02 Ali Kheyrollahi <notifications@github.com wrote:

Hi Jakub,

Essentially CacheCow's client story is done as a delegating handler which gets added to an HttpClient. So the application is responsible for creating the HttpClient as such would be involved in passing a singleton CachingHandler whenever client is created, i.e. CacheCow is oblivious to the process - hence no work required.

CacheCow provides some helpers in the ClientExtensions to build the HttpClient. I guess they just need to be avoided - I might review in the future to remove them.

Does it help?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aliostad/CacheCow/issues/228#issuecomment-458319617, or mute the thread https://github.com/notifications/unsubscribe-auth/ABsWjxHmBHEdKZgfy7cOw9uyf6kBIn3uks5vH3OPgaJpZM4aUG29 .