我在 rails 4.0.3 / unicorn 下有一个葡萄 api。
如果我使用 curl 发出请求,那么返回的“etag”似乎丢失了。但是如果我对'swagger UI'做同样的事情,那么etag就会出现在下一个请求中+缓存也可以工作。
在浏览器中:
- 第一个请求:
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"
-第二个请求:
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
我无法用 curl 检查所有这些,因为这是我收到的标题:
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
如果我向应用程序的根发出 curl 请求,则返回 ETAG:
curl -I --header "授权: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"
欢迎任何解释......似乎葡萄正在去除卷曲的ETAG......(但这不可能发生......显然......)