Skip to content

Instantly share code, notes, and snippets.

@bxcodec
Forked from jaredhirsch/gist:4963424
Created December 21, 2018 14:22
Show Gist options
  • Select an option

  • Save bxcodec/92201e2035a1d580b251fcafad1721bf to your computer and use it in GitHub Desktop.

Select an option

Save bxcodec/92201e2035a1d580b251fcafad1721bf to your computer and use it in GitHub Desktop.

Revisions

  1. @jaredhirsch jaredhirsch revised this gist Feb 15, 2013. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,5 @@
    # ETags & If-None-Match headers: a dialogue

    ### Because the 304 has no response body, client and server save bytes & time.

    GET requests with ```If-None-Match``` headers are called **conditional GET** requests, since the server only returns a response body if there's new content. You can also use date-based validation to issue conditional GETs, saving transfer bandwidth without implementing ETags. The flow is the same, except the server sends down an ```Expires``` date, and the browser sends it back as a ```Last-Modified``` header.

    See the [HTTP 1.1 RFC](http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2) for more details. It's more readable than you'd think.

    ### 1st request.

    browser: **can haz foo?**
    @@ -47,6 +41,10 @@ server: **lol wut! herez latest**

    <!doctype html><p>new foo.

    ### Because the 304 has no response body, client and server save bytes & time.

    GET requests with ```If-None-Match``` headers are called **conditional GET** requests, since the server only returns a response body if there's new content. You can also use date-based validation to issue conditional GETs, saving transfer bandwidth without implementing ETags. The flow is the same, except the server sends down an ```Expires``` date, and the browser sends it back as a ```Last-Modified``` header.

    See the [HTTP 1.1 RFC](http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2) for more details. It's more readable than you'd think.

    Also, those are valid html5 documents in the examples; I just omitted [optional tags](http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#syntax-tag-omission).
  2. @jaredhirsch jaredhirsch revised this gist Feb 15, 2013. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    # ETags & If-None-Match headers: a dialogue

    ### Because the 304 has no response body, client and server save bytes & time.

    GET requests with ```If-None-Match``` headers are called **conditional GET** requests, since the server only returns a response body if there's new content. You can also use date-based validation to issue conditional GETs, saving transfer bandwidth without implementing ETags. The flow is the same, except the server sends down an ```Expires``` date, and the browser sends it back as a ```Last-Modified``` header.

    See the [HTTP 1.1 RFC](http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2) for more details. It's more readable than you'd think.

    ### 1st request.

    browser: **can haz foo?**
    @@ -41,10 +47,6 @@ server: **lol wut! herez latest**

    <!doctype html><p>new foo.

    ### Because the 304 has no response body, client and server save bytes & time.

    GET requests with ```If-None-Match``` headers are called **conditional GET** requests, since the server only returns a response body if there's new content. You can also use date-based validation to issue conditional GETs, saving transfer bandwidth without implementing ETags. The flow is the same, except the server sends down an ```Expires``` date, and the browser sends it back as a ```Last-Modified``` header.

    See the [HTTP 1.1 RFC](http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2) for more details. It's more readable than you'd think.

    Also, those are valid html5 documents in the examples; I just omitted [optional tags](http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#syntax-tag-omission).
  3. @jaredhirsch jaredhirsch revised this gist Feb 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ browser: **can haz foo?**

    ### 1st response.

    server: **o hai, dis page version 12345.**
    server: **o hai, dis version 12345.**

    note, there's always an empty line between headers & body.

  4. @jaredhirsch jaredhirsch revised this gist Feb 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ### 1st request.

    browser: **can haz /foo?**
    browser: **can haz foo?**

    GET /foo HTTP/1.1

  5. @jaredhirsch jaredhirsch revised this gist Feb 15, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ browser: **can haz /foo?**

    ### 1st response.

    server: **o hai, dis page version is 12345.**
    server: **o hai, dis page version 12345.**

    note, there's always an empty line between headers & body.

    @@ -26,7 +26,7 @@ browser: **hai. can haz latest? i haz 12345.**

    ### 2nd response if current version is unchanged

    server: **you haz latest!**
    server: **u haz latest lol!**

    HTTP/1.1 304 Not Modified

    @@ -39,7 +39,7 @@ server: **lol wut! herez latest**
    HTTP/1.1 200 OK
    ETag: "56789"

    <!doctype html><p>foo. too.
    <!doctype html><p>new foo.

    ### Because the 304 has no response body, client and server save bytes & time.

  6. @jaredhirsch jaredhirsch renamed this gist Feb 15, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. @jaredhirsch jaredhirsch created this gist Feb 15, 2013.
    50 changes: 50 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    # ETags & If-None-Match headers: a dialogue

    ### 1st request.

    browser: **can haz /foo?**

    GET /foo HTTP/1.1

    ### 1st response.

    server: **o hai, dis page version is 12345.**

    note, there's always an empty line between headers & body.

    HTTP/1.1 200 OK
    ETag: "12345"

    <!doctype html><p>foo.

    ### 2nd request.

    browser: **hai. can haz latest? i haz 12345.**

    GET /foo HTTP/1.1
    If-None-Match: "12345"

    ### 2nd response if current version is unchanged

    server: **you haz latest!**

    HTTP/1.1 304 Not Modified

    ### 2nd response if current version has changed

    if page has changed + new version is 56789,

    server: **lol wut! herez latest**

    HTTP/1.1 200 OK
    ETag: "56789"

    <!doctype html><p>foo. too.

    ### Because the 304 has no response body, client and server save bytes & time.

    GET requests with ```If-None-Match``` headers are called **conditional GET** requests, since the server only returns a response body if there's new content. You can also use date-based validation to issue conditional GETs, saving transfer bandwidth without implementing ETags. The flow is the same, except the server sends down an ```Expires``` date, and the browser sends it back as a ```Last-Modified``` header.

    See the [HTTP 1.1 RFC](http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2) for more details. It's more readable than you'd think.

    Also, those are valid html5 documents in the examples; I just omitted [optional tags](http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#syntax-tag-omission).