{"_id":"56623a2d0299ea0d008f2cf6","user":"54d4ec36f6c48a0d00f0f040","project":"54d4ecb5f6c48a0d00f0f041","version":{"_id":"563a2dba1846790d00895309","__v":3,"project":"54d4ecb5f6c48a0d00f0f041","createdAt":"2015-11-04T16:09:30.844Z","releaseDate":"2015-11-04T16:09:30.844Z","categories":["563a2dbb1846790d0089530a","563a2dbb1846790d0089530b","563a2dbb1846790d0089530c","56620e60f183880d004d3217","5702e5b8f2d6f336005e9025"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"No Mashape","version_clean":"1.1.0","version":"1.1"},"__v":6,"category":{"_id":"563a2dbb1846790d0089530a","__v":3,"pages":["563a2dbc1846790d0089530f","563a2dbc1846790d00895310","563a2dbc1846790d00895311","563a2dbc1846790d00895312","563a2dbc1846790d00895313","563a2dbc1846790d00895314","563a2dbc1846790d00895315","563a2dbc1846790d00895316","563a2dbc1846790d00895317","566232310299ea0d008f2cf2","56623a2d0299ea0d008f2cf6"],"project":"54d4ecb5f6c48a0d00f0f041","version":"563a2dba1846790d00895309","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-06T16:32:54.503Z","from_sync":false,"order":2,"slug":"documentation","title":"Documentation"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-05T01:13:17.698Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"Most responses return an **etag** header. You can use the value of this header to make subsequent requests to those resources using the If-None-Match header. If the resource has not changed, the server will return a **304 Not Modified**.\n\nFor example, the following is a hypothetical list of headers returned from a GET request for a counter:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"cache-control: no-transform, max-age=60\\ncontent-length: 374\\ncontent-type: application/vnd.instacount.v1+json\\ndate: Sat, 05 Dec 2015 01:06:38 GMT\\netag: \\\"1336826694\\\"\\nserver: Google Frontend\\nstatus: 200\\nvary: Accept, X-Instacount-Application-Id\\nx-ratelimit-access-counters-limit: 1500000\\nx-ratelimit-access-counters-remaining: 1500000\\nx-ratelimit-mutate-counters-limit: 150000\\nx-ratelimit-mutate-counters-remaining: 150000\",\n      \"language\": \"http\",\n      \"name\": \"Not Modified Response\"\n    }\n  ]\n}\n[/block]\nUsing the etag header, we can make a request to the API by specifying the If-None-Match header like the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X GET \\\\\\n  -H \\\"Accept: application/vnd.instacount.v1+json\\\" \\\\\\n  -H \\\"Content-Type: application/vnd.instacount.v1+json\\\" \\\\\\n  -H \\\"X-Instacount-Application-Id: foo\\\" \\\\\\n  -H \\\"X-Instacount-API-Key: bar\\\" \\\\\\n  -H \\\"If-None-Match: \\\"1336826694\\\"\\\" \\\\\\n  -H \\\"Cache-Control: no-cache\\\" \\\\\\n  -H \\\"User-Agent: test-app\\\" \\\\\\n'https://api.instacount.io/sharded_counters/123'\",\n      \"language\": \"curl\",\n      \"name\": \"GET a counter using the If-None-Match header with an etag value\"\n    }\n  ]\n}\n[/block]\nThe expected HTTP response code would be **HTTP/1.1 304 Not Modified**.","excerpt":"","slug":"conditional-requests","type":"basic","title":"Conditional Requests"}

Conditional Requests


Most responses return an **etag** header. You can use the value of this header to make subsequent requests to those resources using the If-None-Match header. If the resource has not changed, the server will return a **304 Not Modified**. For example, the following is a hypothetical list of headers returned from a GET request for a counter: [block:code] { "codes": [ { "code": "cache-control: no-transform, max-age=60\ncontent-length: 374\ncontent-type: application/vnd.instacount.v1+json\ndate: Sat, 05 Dec 2015 01:06:38 GMT\netag: \"1336826694\"\nserver: Google Frontend\nstatus: 200\nvary: Accept, X-Instacount-Application-Id\nx-ratelimit-access-counters-limit: 1500000\nx-ratelimit-access-counters-remaining: 1500000\nx-ratelimit-mutate-counters-limit: 150000\nx-ratelimit-mutate-counters-remaining: 150000", "language": "http", "name": "Not Modified Response" } ] } [/block] Using the etag header, we can make a request to the API by specifying the If-None-Match header like the following: [block:code] { "codes": [ { "code": "curl -X GET \\\n -H \"Accept: application/vnd.instacount.v1+json\" \\\n -H \"Content-Type: application/vnd.instacount.v1+json\" \\\n -H \"X-Instacount-Application-Id: foo\" \\\n -H \"X-Instacount-API-Key: bar\" \\\n -H \"If-None-Match: \"1336826694\"\" \\\n -H \"Cache-Control: no-cache\" \\\n -H \"User-Agent: test-app\" \\\n'https://api.instacount.io/sharded_counters/123'", "language": "curl", "name": "GET a counter using the If-None-Match header with an etag value" } ] } [/block] The expected HTTP response code would be **HTTP/1.1 304 Not Modified**.