System.Net.Http.HttpClient caching behavior

后端 未结 2 1890
余生分开走
余生分开走 2020-12-18 19:06

I\'m using HttpClient 0.6.0 from NuGet.

I have the following C# code:

var client = new HttpClient(new WebRequestHandler() {
    CachePolicy =
                


        
2条回答
  •  轮回少年
    2020-12-18 19:36

    Answering my own question..

    According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.4 I would say that a "Cache-Control: must-revalidate" without expiration states that the resource should be validated on every request.

    In this case it means a conditional GET should be done every time the resource is made. So in this case System.Net.Http.HttpClient is behaving correctly and the legacy (Http)WebRequest is doing invalid behavior.

提交回复
热议问题