aliostad / CacheCow

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

Support HttpClientFactory #295

Closed SeanFarrow closed 7 months ago

SeanFarrow commented 7 months ago

I really like this library, however it would be really nice to have IHttpclientFactory support along with dependency injection.

I'm happy to do the work if a PR would be accepted.

aliostad commented 7 months ago

hi,

Yes please - I cannot guarantee your PR would be merged depending on the impl but most likely it will.

aliostad commented 7 months ago

So, I fail to see how this would be responsibility of this library. In your own application, you need to register an implementation of IHttpClientFactory which constructs it as you wish, no? You just need to ensure to get a singleton version of the CachingHandler to use all the benefits.

All of this, is responsibility of the client application. I will try to implement in one of the samples.

aliostad commented 7 months ago

Actually this is how you need to do it is explained here:

https://stackoverflow.com/questions/50747749/how-to-use-httpclienthandler-with-httpclientfactory-in-net-core