Marvin.Cache.Headers 6.0.0 Available Now

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(). 

app.UseRouting();

app.UseHttpCacheHeaders();

app.UseEndpoints(…);

For more info, have a look at the milestone over on GitHub.

Happy coding! :)

 Tweet about this on TwitterShare on LinkedInShare on Facebook

Leave a Reply

Your email address will not be published. Required fields are marked *