etag - Wininet not caching compressed content -


i have compressed resource when viewed in ie, loads cache expected. when application loads same url, wininet ignores cache , downloads content server. dynamic content compression disabled on iis, application behaves same ie (the http includes if-none-match header.)

what can app behave same ie?

_httpclient = new httpclient(new webrequesthandler {     cachepolicy = new httprequestcachepolicy(httprequestcachelevel.default),     automaticdecompression = decompressionmethods.deflate | decompressionmethods.gzip });  using (task<httpresponsemessage> tget = _httpclient.getasync(uri, httpcompletionoption.responseheadersread, _cancel)) {     tget.wait();     response = tget.result; } 

the http headers application's get:

get https://beautykiosktest.coinstar.com/conductor/configuration/files/promos.xml?kioskid=eng20130027 http/1.1 accept: */* accept-language: en-us user-agent: configurationservice/2.3.0.0 host: beautykiosktest.coinstar.com accept-encoding: gzip, deflate  http/1.1 200 ok cache-control: max-age=30 transfer-encoding: chunked content-type: application/xml; charset=utf-8 content-encoding: gzip etag: "chmrx5fp2z+etv/qixis2a==" vary: accept-encoding server: microsoft-iis/8.5 x-aspnet-version: 4.0.30319 x-powered-by: asp.net date: tue, 17 mar 2015 00:39:18 gmt 

ie's 304 response expect

get https://beautykiosktest.coinstar.com/conductor/configuration/files/promos.xml?kioskid=eng20130027 http/1.1 accept: image/jpeg, image/gif, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* accept-language: en-us user-agent: mozilla/4.0 (compatible; msie 7.0; windows nt 6.1; wow64; trident/7.0; slcc2; .net clr 2.0.50727; infopath.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-none-match: "chmrx5fp2z+etv/qixis2a==" dnt: 1 connection: keep-alive  http/1.1 304 not modified cache-control: max-age=30 etag: "chmrx5fp2z+etv/qixis2a==" server: microsoft-iis/8.5 x-aspnet-version: 4.0.30319 x-powered-by: asp.net date: tue, 17 mar 2015 00:42:13 gmt 

i ended filing ticket microsoft resolve , found out there bug in .net 4 causes this. problem cache entry populated response vary header doesn't matched on next because though automaticdecompression property set, .net hasn't added accept-encoding header request before doing wininet cache test.

the workaround/fix add "accept-encoding" default header httpclient instance before using it.

_httpclient.defaultrequestheaders.add("accept-encoding", "gzip, deflate"); 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

ios - Possible to get UIButton sizeThatFits to work? -