title: How to mix compression and caching in HttpWebRequest?
body: <p>I have a c# client talking to a cherrypy(http/rest) webservice.
  The problem is i can't both turn on compression and caching at the same time.</p>
  
  <pre><code>request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
  </code></pre>
  
  <p>By leaving out the above line I get the correct caching headers (If-None-Math,If-Modified-Since) while commenting it out gets me the compression headers (Accept-Encodig:gzip) but not the caching headers. It seems to me like a bug but maybe i'm doing something wrong.</p>
  
  <p>[full code]</p>
  
  <pre><code>        public static string GET(string URL)
      {
          string JSON;
          // Create the web request  
          HttpWebRequest request = WebRequest.Create(URL) as HttpWebRequest;
          HttpRequestCachePolicy cPolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Revalidate);
  
          request.Accept = "application/json";            
          request.CachePolicy = cPolicy;
          request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
          request.Pipelined = false;
  
          // Get response  
          using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
          {                
              // Get the response stream  
              StreamReader readerF = new StreamReader(response.GetResponseStream());
  
              JSON = readerF.ReadToEnd();
              // Console application output  
              //Console.WriteLine(JSON);
              if (response.IsFromCache )
                  Console.WriteLine("Request not from cache");
          }
  
          return JSON;
      }
  </code></pre>