KevinDockx / HttpCacheHeaders

ASP.NET Core middleware that adds HttpCache headers to responses (Cache-Control, Expires, ETag, Last-Modified), and implements cache expiration & validation models
MIT License
271 stars 57 forks source link

support for override middleware #97

Closed YusufMavzer closed 3 years ago

YusufMavzer commented 3 years ago

For our use case we need to bypass the caching for some endpoint.

Without over bloating the library it would nice to give us more flexibility to inherit from it.

YusufMavzer commented 3 years ago

@KevinDockx Could you merge this in?

KevinDockx commented 3 years ago

@YusufMavzer : first of all, thanks for the PR - I appreciate it. However, I'd prefer not to merge it as such - it will work, but by allowing overriding the Invoke method and making the next delegate protected instead of private the middleware is open to unknown manipulation from outside of the middleware itself. It's generally not a good idea to allow that.

That said, I do agree with you: allowing to bypass certain routes is certainly a useful feature. I just added it with this commit: https://github.com/KevinDockx/HttpCacheHeaders/commit/8154cc0b7febaf6ee7c8a043311736c14a71ad77 => you can now use the [HttpCacheIgnore] attribute at level of any controller or controller action to ignore the respective route(s). Hope this helps! :)

YusufMavzer commented 3 years ago

Hi,

Thanks for the new feature. This does solve our problem too :)