Closed toddb closed 10 months ago
I never considered that someone would want to not provide the response body for eTag generation, but if you have a need for that I'm open to making this pluggable. Strategy pattern indeed seems like the way to go, I'd be happy to have a look at a PR. Thanks! :)
Released (beta): https://www.nuget.org/packages/Marvin.Cache.Headers/7.1.0-beta
Currently, I believe, there is only one implementation of generating the string that is provided for the eTag generation. This implementation requires reading the response body:
While this implementation requires reading the payload each time (which can be a problem), it doesn't allow for alternative strategies, such as, retrieving an previously generated eTag for that resource (that could be outside of this implementation). This can be useful for say computationally large, but immutable, resources.
At this stage, I am just proposing an implementation that makes the code above injected as a strategy and is the default strategy. Effectively, I see that interface accepts an HttpContext and then the default implementation is the same. The would be transparent is an upgrade but allow a service to be injected.
Because I haven't done the implementation/tests, I am trying to work out if the return type. I quick looks suggests the 'ValidatorValue' that wraps eTag/LastModified. I suspect it isn't the string because if we already know the eTag we don't want the cost of regeneration.
A first version probably only includes:
I could then add:
@KevinDockx Any thoughts? Problems? Does this make enough sense to proceed? Or would it not get any further and is a waste of time?
ps, thanks for the work on the library and I am offering that I will do the work/submit a PR as I need for my production system.