Skip to content

Instantly share code, notes, and snippets.

@mheadd mheadd/ETags.md
Last active Aug 29, 2015

Embed
What would you like to do?

Get a list of documents

curl http://127.0.0.1:5984/example/_all_docs

{
  "rows": [
    {
      "value": {
        "rev": "2-13839535feb250d3d8290998b8af17c3"
      },
      "key": "5c8022985a07611bff60efe850043d16",
      "id": "5c8022985a07611bff60efe850043d16"
    }
  ],
  "offset": 0,
  "total_rows": 1
}

Get a specific document (returned with ETag value)

curl -v http://127.0.0.1:5984/example/5c8022985a07611bff60efe850043d16

* About to connect() to 127.0.0.1 port 5984 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x7fe09b804000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fe09b804000) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> GET /example/5c8022985a07611bff60efe850043d16 HTTP/1.1
> User-Agent: curl/7.30.0
> Host: 127.0.0.1:5984
> Accept: */*
> 
< HTTP/1.1 200 OK
* Server CouchDB/1.6.0 (Erlang OTP/R16B01) is not blacklisted
< Server: CouchDB/1.6.0 (Erlang OTP/R16B01)
< ETag: "2-13839535feb250d3d8290998b8af17c3"
< Date: Sun, 07 Sep 2014 15:12:26 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 99
< Cache-Control: must-revalidate
< 
{"_id":"5c8022985a07611bff60efe850043d16","_rev":"2-13839535feb250d3d8290998b8af17c3","foo":"bar"}
* Connection #0 to host 127.0.0.1 left intact

Make request for document (send ETag value in request)

curl -v http://127.0.0.1:5984/example/5c8022985a07611bff60efe850043d16 -H 'If-None-Match: "2-13839535feb250d3d8290998b8af17c3"

* About to connect() to 127.0.0.1 port 5984 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x7fedc2804000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fedc2804000) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> GET /example/5c8022985a07611bff60efe850043d16 HTTP/1.1
> User-Agent: curl/7.30.0
> Host: 127.0.0.1:5984
> Accept: */*
> If-None-Match: "2-13839535feb250d3d8290998b8af17c3"
> 
< HTTP/1.1 304 Not Modified
* Server CouchDB/1.6.0 (Erlang OTP/R16B01) is not blacklisted
< Server: CouchDB/1.6.0 (Erlang OTP/R16B01)
< ETag: "2-13839535feb250d3d8290998b8af17c3"
< Date: Sun, 07 Sep 2014 14:56:31 GMT
< Content-Length: 0
< 
* Connection #0 to host 127.0.0.1 left intact
* 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.