locked
Windows.Web.Http.HttpClient - turn off caching. RRS feed

  • Question

  • Windows.Web.Http.HttpClient by default sends a few headers like

    If-None-Match

    If-Modified-Since

    Proxy-Connection

    etc.

    I tried, httpClient.DefaultRequestHeaders.Clear(). Doesn't work.

    Any help is appreciated?

    Basically, I manage my own caching and don't want the client to send extra headers that the server hates.

    Wednesday, December 18, 2013 8:42 AM

Answers

  • try to set this:

    RootFilter = new HttpBaseProtocolFilter();
    

    RootFilter.CacheControl.ReadBehavior = Windows.Web.Http.Filters.HttpCacheReadBehavior.MostRecent; RootFilter.CacheControl.WriteBehavior = Windows.Web.Http.Filters.HttpCacheWriteBehavior.NoCache;

    HttpClient = new HttpClient(RootFilter)

                


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    • Marked as answer by basanjeev Sunday, December 22, 2013 11:46 PM
    • Unmarked as answer by basanjeev Sunday, December 22, 2013 11:46 PM
    • Marked as answer by basanjeev Sunday, December 22, 2013 11:47 PM
    Wednesday, December 18, 2013 12:49 PM

All replies

  • try to set this:

    RootFilter = new HttpBaseProtocolFilter();
    

    RootFilter.CacheControl.ReadBehavior = Windows.Web.Http.Filters.HttpCacheReadBehavior.MostRecent; RootFilter.CacheControl.WriteBehavior = Windows.Web.Http.Filters.HttpCacheWriteBehavior.NoCache;

    HttpClient = new HttpClient(RootFilter)

                


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    • Marked as answer by basanjeev Sunday, December 22, 2013 11:46 PM
    • Unmarked as answer by basanjeev Sunday, December 22, 2013 11:46 PM
    • Marked as answer by basanjeev Sunday, December 22, 2013 11:47 PM
    Wednesday, December 18, 2013 12:49 PM
  • Yes. That setting works.

    Thanks.

    Sunday, December 22, 2013 11:47 PM
  • If we use a HttpClienthAndler to obtain the cookie container... How to use HttpBaseProtocolFilter combined with  CookieContainer to inicialize httpclient?



    • Edited by BlackCid Sunday, April 5, 2015 10:32 AM
    Sunday, April 5, 2015 10:30 AM