title: When does Rails respond with 'transfer-encoding' vs. 'content-length'?
body: <p>I'm building an API on Rails version 4.1.7/Nginx that responds to request from an iOS app. We're seeing some weird caching on the client and we think it has something to do with a small difference in the response that Rails is sending back. My questions...</p>
  
  <p>1) I want to understand why, for the exact same request (with only the Authorization header value changed), Rails sends back <code>transfer-encoding: chunked</code> sometimes and <code>Content-Length: &lt;number&gt;</code> sometimes? I thought that maybe it had something to do with the response size, but in the example responses whose headers I've pasted below, the data returned in the body is EXACTLY the same.</p>
  
  <p>2) Is there a way to force it to use <code>Content-Length</code>? We think that that will fix our caching issues in our iOS app.</p>
  
  <p>Response #1</p>
  
  <pre><code>HTTP/1.1 200 OK
  Cache-Control: max-age=0, private, must-revalidate
  Content-Type: application/json; charset=utf-8
  Date: Wed, 18 Mar 2015 00:59:31 GMT
  ETag: "86f277ea63295460d4f3bed9a073eaa2"
  Server: nginx/1.6.2
  Status: 200 OK
  X-Content-Type-Options: nosniff
  X-Frame-Options: SAMEORIGIN
  X-Request-Id: dd36f139-1986-4da6-9645-4438d41e74b0
  X-Runtime: 0.123865
  X-XSS-Protection: 1; mode=block
  transfer-encoding: chunked
  Connection: keep-alive
  </code></pre>
  
  <p>Request #2</p>
  
  <pre><code>HTTP/1.1 200 OK
  Cache-Control: max-age=0, private, must-revalidate
  Content-Type: application/json; charset=utf-8
  Date: Wed, 18 Mar 2015 00:59:36 GMT
  ETag: "86f277ea63295460d4f3bed9a073eaa2"
  Server: nginx/1.6.2
  Status: 200 OK
  X-Content-Type-Options: nosniff
  X-Frame-Options: SAMEORIGIN
  X-Request-Id: 0cfd7705-157b-41b5-aa36-739bc6f8302e
  X-Runtime: 0.092672
  X-XSS-Protection: 1; mode=block
  Content-Length: 2234
  Connection: keep-alive
  </code></pre>