I’ve been working on some caching strategies and some unit tests to go with them. I was getting some unexpected results and not sure if my expectations are wrong or if it’s code.
Specifically, I have an endpoint decorated with
[CacheResponse(VaryByUser = true)]
and returns
return new HttpResult(converstion, converstion == null ? HttpStatusCode.NoContent : HttpStatusCode.OK)
{
LastModified = converstion?.Max(x => x.ModifiedDate),
CacheControl = DefaultCacheControl
};
When I use the CachedServiceClient to make a call to the endpoint I expect to see a cached entry based on the Last-Modified I return. However, if I follow through the code in CachedServiceClient.OnResultsFilterResponse I notice that
var lastModifiedStr = webRes.Headers[HttpHeaders.LastModified];
Doesn’t return a value. There is no header. Instead, the WebResponse object has a property LastModified that does have the correct value - but it’s not looked at.
So, what should i be expecting here? Am i missing something or looking at this incorrectly?