Implementing a cache with a configurable TTL as well as a configurable maximum size in ClientProvider could be very useful to help preventing unnecessary load on whatever service or infrastructure component ClientProvider's getClientByTokenFunc function is calling.
The implementation:
Must be able to have a maximum cache size (e.g. 10000)
Must be able to have a configurable TTL (e.g. 1 hour)
Must be able to cache invalid tokens with a shorter entry TTL (e.g. 30 minutes)
Being the self-promoting person that I am, I think TwinProduction/gocache would fit this role perfectly.
Rather than only supporting the Authorization header as a way to identify a user, it would be nice if we could use the client provider to retrieve the user through a session cookie.
At present it looks like the client provider cache field is tightly coupled to the gocache.
If a user wants to also use an external/shared/distributed cache then this isn't possible.
It would be nice to allow more flexibility to the user in which caching solution they wish to use.
Why do you personally want this feature to be implemented?