aliostad / CacheCow

An implementation of HTTP Caching in .NET Core and 4.5.2+ for both the client and the server
MIT License
849 stars 171 forks source link

Cachecow.Client InMemoryCacheStore #185

Closed HaripraghashSubramaniam closed 7 years ago

HaripraghashSubramaniam commented 7 years ago

The InMemoryCacheStore, if the Content property of the HttpResponseMessage is null, seems to use the expires header rather than the Max-Age value. But then, in the call stack above the call to store the response in ObjectCache, Expires header is being cleared off and therefore it uses the default cache time(06:00 hrs).

`if (response.Content == null)
            {
                return response.Headers.CacheControl != null && response.Headers.CacheControl.MaxAge.HasValue
                           ? DateTimeOffset.UtcNow.Add(response.Headers.CacheControl.MaxAge.Value)
                           : DateTimeOffset.UtcNow.Add(_defaultExpiry);

            }
            else
            {
// Expires will always be null as it is being explicity cleared off in cachinghandler.
                return response.Content.Headers.Expires.HasValue
                           ? response.Content.Headers.Expires.Value
                           : DateTimeOffset.UtcNow.Add(_defaultExpiry);
            }`
aliostad commented 7 years ago

Thank you Harri. This has been implemented so in https://github.com/aliostad/CacheCow/blob/master/src/CacheCow.Client/CachingHandler.cs#L240

But left out on this case.

aliostad commented 7 years ago

Releasing 1.3.2

HaripraghashSubramaniam commented 7 years ago

Great. Thanks Ali