I just pushed a new release of Marvin.Cache.Headers to NuGet. This feature release adds a new extension point (via ILastModifiedInjector) that allows injecting the LastModified date for resources for which you explicitly know that date.
By default the middleware assumes the LastModified date is the date at which the request first hits the middleware. In a lot of cases that’s what you want, but in some cases you might, for example, have those dates stores in a database. If that’s the case, the date should come from that store instead.
The ILastModifiedInjector looks as such:
/// <summary> /// Contract for a LastModifiedInjector, which can be used to inject custom last modified dates for resources /// of which you know when they were last modified (eg: a DB timestamp, custom logic, ...) /// </summary> public interface ILastModifiedInjector { Task<DateTimeOffset> CalculateLastModified( ResourceContext context); }
Via the ResourceContext you get access to the StoreKey and the full HttpRequest. That info should allow you to correctly identify the resource.
For questions, issues, … check the GitHub project. Happy coding!