title: ETag and If-None-Match HTTP Headers are not working
body: <p>I have a file in my <em>webserver</em> and I am downloading that to my app everytime I access it because its possible that file content might be changed But If it is changed I would like to download that time only so bandwidth can be saved and fortunately that's what this <strong>ETag</strong> and <strong>If-None-Match</strong> <em>header fields</em> are for.</p>
  
  <ul>
  <li>When I make a request first time ,I retrieve the <em>ETag</em> from the HTTP response headers </li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/7JBSo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7JBSo.png" alt="First time request to the file"></a></p>
  
  <ul>
  <li><p>In the subsequent requests to download that file I'd attach the <em>Etag</em> value for <em>If-None-Match</em> headerfield so that if there is no change then I'd get HTTP response status code 304 or else I'd get 200 if there is a change in the file.</p>
  
  <p><a href="https://i.stack.imgur.com/PAE6X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PAE6X.png" alt="Second time request for same file"></a></p></li>
  </ul>
  
  <p><em>Note:</em></p>
  
  <p>When I try the above steps in <strong>Advanced REST Client Application</strong> in chrome it works fine as it is supposed to be but when I try that in iOS I always get the response code 200 but it should have given me 304 for the subsequent requests.</p>
  
  <p>Here is the sample code I use</p>
  
  <pre><code>var request1 =  NSMutableURLRequest(URL:NSURL(string: "http://10.12.1.101/Etag/ringtone1.mp3")!)
  let Etagvalue="\"36170-52c1cc36d9b40\""
  var session1 = NSURLSession.sharedSession()
  request1.HTTPMethod = "GET"
  var err: NSError?
  request1.addValue(Etagvalue, forHTTPHeaderField: "If-None-Match")
  
  var task = session1.dataTaskWithRequest(request1, completionHandler: {data, response, error -&gt; Void in
         print("response: \(response)")
  
  })
  </code></pre>
  
  <p>Here is the response</p>
  
  <blockquote>
    <p>response: Optional( { URL:
    <a href="http://10.12.1.101/Etag/ringtone1.mp3" rel="noreferrer">http://10.12.1.101/Etag/ringtone1.mp3</a> } { status code: 200, headers {
        "Accept-Ranges" = bytes;
        Connection = "Keep-Alive";
        "Content-Length" = 221552;
        "Content-Type" = "audio/mpeg";
        Date = "Wed, 24 Feb 2016 14:57:53 GMT";
        Etag = "\"36170-52c1cc36d9b40\"";
        "Keep-Alive" = "timeout=5, max=100";
        "Last-Modified" = "Fri, 19 Feb 2016 10:15:33 GMT";
        Server = "Apache/2.4.16 (Unix) PHP/5.5.29"; } })</p>
  </blockquote>
  
  <p>What am I doing wrong here ?</p>