ZiggyCreatures / FusionCache

FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
MIT License
1.87k stars 96 forks source link

[BUG] System.Net.Http.HttpRequestException: Response status code does not indicate success: 304 (Not Modified). #283

Closed onionhammer closed 3 months ago

onionhammer commented 3 months ago

Describe the bug

This appears to be a bug in the documentation, but if you follow this guide: https://github.com/ZiggyCreatures/FusionCache/blob/main/docs/ConditionalRefresh.md#-a-practical-example

Calling 'EnsureSuccessStatusCode' will fail if the server really does reply with 304 not modified, because that is not considered a "success code"

https://learn.microsoft.com/en-us/uwp/api/windows.web.http.httpresponsemessage.ensuresuccessstatuscode?view=winrt-26100#remarks

If the server doesn't return a successful HttpStatusCode in the Successful range (200-299) for the request, then the HttpResponseMessage.IsSuccessStatusCode property is set to false. Calling EnsureSuccessStatusCode causes the value of IsSuccessStatusCode to be checked, and an exception thrown if that value is false. No exception is thrown if the value is true.

jodydonetti commented 3 months ago

Hi @onionhammer , good catch, thanks!

PR merged.