Monday, 15 February 2010

etag - Wininet not caching compressed content -


I have a compressed resource, when seen in IE, loads from the cache as expected, though The application loads the same URL, Wininet ignores the cache and always downloads the content from the server. With incompetent dynamic content compression on IIS, my application treats like IE (HTTP is included in GET- if there is no-match header).

I used to do my app like IE What can i do for

_httpClient = New HttpClient (New WebRequestHandler {CachePolicy = New HttpRequestCachePolicy (); AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip}); Using (Task & LT; HttpResponseMessage & gt; tget = _httpClient.GetAsync (uri, HttpCompletionOption.ResponseHeadersRead, _cancel)) {tget.Wait (); Feedback = tget.Result; }

Get the HTTP header for my application:

  Obtain https://beautykiosktest.coinstar.com/conductor/configuration/files/Promos. Xml? Kioskid = ENG20130027 Accept HTTP / 1.1: * / * Accept-language: en-US user-agent: ConfigurationService / 2.3.0.0 host: beautykiosktest.coinstar.com Accept-Encoding: gzip, HTTP air-removal / 1.1 200 fine cache -Control: Maximum-age = 30 transfer-encoding: checked content-type: app / xml; Charset = utf-8 content-encoding: gzip etag: "cHmrX5Fp2Z + ETV / qIXiS2A ==" Vary: Accept-encoding server: Microsoft IIS / 8.5x ASPNET-version: 4.0.30319 Operated by X: ASP. Net Date: Tuesday, 17 March 2015 00:39:18 GMT  

What do I expect with IE's 304 response

  get https: / / Beautykiosktest.coinstar.com/conductor/configuration/files/Promos.xml?kioskid=ENG20130027 Accept HTTP / 1.1: image / jpeg, image / gif, image / pjpeg, application / x-ms-application, application / XAML + Xml, application / x-ms-xbip, application / vnd.ms-excel, application / vnd.ms- powerpoint, app / msword, * / * accept-language: n-us US-agent: Mozilla / 4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident / 7.0; SLCC2; .NET CLR 2.0.50727; Info Path.3; .NET4.0C; .NET4.0E; .NET CLR 3.5.30729, .NET CLR 3.0.30729, .NET CLR 1.1.4322) Accept-Encoding: gzip, deflate Host: beautykiosktest.coinstar.com If no-match: "CHMRX5FP2Z + ETV / qIXiS2A ==" DNT: 1 Connection: Keep the API HTTP / 1.1304 Modified Cash - Control: Me Ex-Edge = 30 ETG: "CHMRX5FP2 AG + ETV / CxIS2A == "Server: Microsoft-IIS / 8.5x-espaƱol-version: 4.0.30319 by X-Power: ASP.NET Date: Tuesday, March 17, 2015 00: 42:13 GMT  < / Pre> 

< V class = "post-text" itemprop = "text">

I filed a ticket with Microsoft to finish it and found out that there is a bug in .NET 4 that is due to this. The problem is that a cash entry that is left with a response with a different header, does not match the next GET exactly because even though the automatic decampress asset is set. The NET has not added the accept-encoding header in the request before requesting a WinINET cache test.

Workaround / Fix Before using it, the HTTP Client instance is to add "Act-Encoding" default headers.

  _httpClient.DefaultRequestHeaders.Add ("accept-encoding", "jizip, difflet");  

No comments:

Post a Comment