I just released a new version of Marvin.Cache.Headers. You can find it on NuGet. For those of you who don’t know what that is:
Marvin.Cache.Headers is ASP.NET Core middleware that adds HttpCache headers to responses (Cache-Control, Expires, ETag, Last-Modified), and implements cache expiration & validation models. It can be used to ensure caches correctly cache responses and/or to implement concurrency for REST-based APIs using ETags.
The middleware itself does not store responses. It generates the correct cache-related headers, and ensures a cache can check for expiration (304 Not Modified) & preconditions (412 Precondition Failed) (often used for concurrency checks). It can be used together with a shared cache, a private cache or both. For production scenarios the best approach is to use this middleware to generate the ETags, combined with a cache server or CDN to inspect those tags and effectively cache the responses.
This is quite a big release. Stability has been increased, bugs were fixed, and a new feature that allows ignoring a certain endpoint has been added via the “HttpCacheIgnore” attribute.
The most important – and BREAKING – change is that the middleware must now be added to the request pipeline between the call into UseRouting() and UseEndpoints().
For more info, have a look at the milestone over on GitHub.