Skip to content
This repository has been archived by the owner on Nov 1, 2017. It is now read-only.

Commit

Permalink
Add docs for conditional requests
Browse files Browse the repository at this point in the history
  • Loading branch information
paul committed Jul 6, 2012
1 parent e3df1f1 commit b2116cb
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions content/v3.md
Expand Up @@ -14,6 +14,7 @@ you have any problems or requests please contact
* <a href="#authentication">Authentication</a>
* <a href="#pagination">Pagination</a>
* <a href="#rate-limiting">Rate Limiting</a>
* <a href="#conditional-requests">Conditional Requests</a>
* <a href="#cross-origin-resource-sharing">Cross Origin Resource Sharing</a>
* <a href="#json-p-callbacks">JSON-P Callbacks</a>

Expand Down Expand Up @@ -223,6 +224,46 @@ You can also check your rate limit status without incurring an API hit.
Please [contact us](https://github.com/contact) to request white listed access for your application. We prefer sites that
setup OAuth applications for their users.

## Conditional Requests

Most responses return `Last-Modified` and `Etag` headers. You can use the values
of these headers to make subsequent requests to those resources using the
`If-Modified-Since` and `If-None-Match` headers, respectively. If the resource
has not changed, the server will return a `304 Not Modified`. Also note: making
a conditional request and receiving a 304 response does not count against your
[Rate Limit](#rate-limiting), so we encourage you to use it whenever possible.

<pre class="terminal">
$ curl -i https://api.github.com/user
HTTP/1.1 200 OK
Cache-Control: private, max-age=60
ETag: "644b5b0155e6404a9cc4bd9d8b1ae730"
Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
Status: 200 OK
Vary: Accept, Authorization, Cookie
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4996

$ curl -i https://api.github.com/user -H "If-Modified-Since: Thu, 05 Jul 2012 15:31:30 GMT"
HTTP/1.1 304 Not Modified
Cache-Control: private, max-age=60
Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
Status: 304 Not Modified
Vary: Accept, Authorization, Cookie
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4996

$ curl -i https://api.github.com/user -H 'If-None-Match: "644b5b0155e6404a9cc4bd9d8b1ae730"'
HTTP/1.1 304 Not Modified
Cache-Control: private, max-age=60
ETag: "644b5b0155e6404a9cc4bd9d8b1ae730"
Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
Status: 304 Not Modified
Vary: Accept, Authorization, Cookie
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4996
</pre>

## Cross Origin Resource Sharing

The API supports Cross Origin Resource Sharing (CORS) for AJAX requests.
Expand Down

0 comments on commit b2116cb

Please sign in to comment.