I have a grape api under rails 4.0.3 / unicorn.
If I make the request with curl then it seems like the returned 'etag' is missing. But If I do the same with the 'swagger UI' then the etag is present + in the next request the caching works too.
Within browser:
-first request:
Status Code:200 OK
Cache-Control:max-age=0, private, must-revalidate
Connection:keep-alive
Content-Encoding:gzip
Content-Type:application/json
Date:Tue, 24 Jun 2014 18:43:09 GMT
Etag:"42ab9ced8f83b39e29775b0ca9cc5a6d"
-second request:
Status Code:304 Not Modified
Cache-Control:max-age=0, private, must-revalidate, no-transform
Connection:keep-alive
Date:Tue, 24 Jun 2014 18:43:25 GMT
Etag:"42ab9ced8f83b39e29775b0ca9cc5a6d"
Status:304 Not Modified
I can't check all this with curl because this is the header I receive:
curl -I --header "Authorization:d0294f288597e5979a5655a70ec63b88e" http://.../products.json
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-length: 586957
Content-Type: application/json
Date: Tue, 24 Jun 2014 18:53:34 GMT
Status: 200 OK
Vary: Accept-Encoding
X-Request-Id: 89ec37ea-e675-4c24-8c16-0f2338aafe81
X-Runtime: 0.496127
Connection: keep-alive
If I make a curl request to the root of the application then the ETAG is returned:
curl -I --header "Authorization:d0294f288597e5979a5655a70ec63b88" http://...
HTTP/1.1 200 OK
Cache-Control: max-age=0, private, must-revalidate
Content-length: 3359
Content-Type: text/html; charset=utf-8
Date: Tue, 24 Jun 2014 18:54:13 GMT
Etag: "c9198615bdab1e5ef77bfb9a6890f576"
Any explanations are welcome... It seems like the grape is removing the ETAG for curl... (however this cannot happen... obviously...)
curl -I changed the behaviour of the server so I user 'curl -v'. That way the etag was returned properly + the caching was working fine.