Skip to content

Commit

Permalink
Adds MaxAge cache header to ImageMetaData to prevent unnecessary meta…
Browse files Browse the repository at this point in the history
… data lookups through http
  • Loading branch information
skttl committed Aug 28, 2024
1 parent e946748 commit 3427f18
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ public async Task<ImageMetadata> GetMetaDataAsync()
_logger.LogDebug("LastModified header missing from {Url}", _url);
}

return new ImageMetadata(response.Content.Headers.LastModified.GetValueOrDefault().UtcDateTime, response.Content.Headers.ContentLength.GetValueOrDefault());
if (response.Headers.CacheControl?.MaxAge is null)
{
_logger.LogDebug("MaxAge header is null from {Url}", _url);
}

return new ImageMetadata(response.Content.Headers.LastModified.GetValueOrDefault().UtcDateTime, (response.Headers.CacheControl?.MaxAge).GetValueOrDefault(), response.Content.Headers.ContentLength.GetValueOrDefault());
}

public async Task<Stream> OpenReadAsync()
Expand Down

0 comments on commit 3427f18

Please sign in to comment.