May I ask what are you trying to achieve? Trying to Avoid Caching?
Reason for the request: I looked at the source code for HttpClient (specifically HttpClientHandler ) and the source for HttpWebResponse , and I do not believe that you can get this information from the headers.
The HttpClient / HttpClientHandler uses the HttpWebResponse internally, but does not disclose all the properties from the HttpWebResponse :
private HttpResponseMessage CreateResponseMessage(HttpWebResponse webResponse, HttpRequestMessage request) { HttpResponseMessage httpResponseMessage = new HttpResponseMessage(webResponse.StatusCode); httpResponseMessage.ReasonPhrase = webResponse.StatusDescription; httpResponseMessage.Version = webResponse.ProtocolVersion; httpResponseMessage.RequestMessage = request; httpResponseMessage.Content = (HttpContent) new StreamContent((Stream) new HttpClientHandler.WebExceptionWrapperStream(webResponse.GetResponseStream()));
So, your options, as I see it, are:
a) Look at the source code for HttpWebRequest to determine the logic for IsFromCache and somehow modify it in HttpClient (it may even be impossible, it depends on what the logic actually does / needs)
b) ask the ASP.NET team to include this property in the HttpResponseMessage. either directly as a property, or perhaps they can "save" HttpWebResponse
None of these options are too bad, so my original question is, what are you trying to achieve?
source share