Beta Release: Marvin.Cache.Headers – ASP.NET Core Middleware for Generating Cache-related Response Headers

Recently I was working on a few demos in ASP.NET Core for an upcoming Pluralsight course, and I needed something that was able to generate cache-related response headers: Cache-Control, Expires, ETag and Last-Modified, and returns 304 – Not Modified or 412 – Precondition Failed responses when needed.  Currently, that’s not included – there’s a ResponseCaching attribute available in ASP.NET Core MVC that can be used to annotate actions with and will result in the generation of a Cache-Control and Expires header, but as it doesn’t generate ETags (strong nor weak), it shouldn’t be used for validation. 

In other words: it supports the cache Expiration model, but not the Validation model (more on that can be found here).  I needed more, and figured I wouldn’t be the only one.  And with that, the Marvin.Cache.Headers middleware was born :-)

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.

Today, the first version was released on NuGet. It’s a pre-release version, so issues might occur – if you notice one of those, or you want to help out, one address: Marvin.Cache.Headers Github.

Thanks go out to Maarten Balliauw and Ken Bonny for the PR’s! :)

Happy coding!

 Tweet about this on TwitterShare on LinkedInShare on Facebook

One Comment

Leave a Reply

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