-
-
Save bxcodec/92201e2035a1d580b251fcafad1721bf to your computer and use it in GitHub Desktop.
Revisions
-
jaredhirsch revised this gist
Feb 15, 2013 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,5 @@ # ETags & If-None-Match headers: a dialogue ### 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). -
jaredhirsch revised this gist
Feb 15, 2013 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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. 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). -
jaredhirsch revised this gist
Feb 15, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ browser: **can haz foo?** ### 1st response. server: **o hai, dis version 12345.** note, there's always an empty line between headers & body. -
jaredhirsch revised this gist
Feb 15, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ ### 1st request. browser: **can haz foo?** GET /foo HTTP/1.1 -
jaredhirsch revised this gist
Feb 15, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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.** 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: **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>new foo. ### Because the 304 has no response body, client and server save bytes & time. -
jaredhirsch renamed this gist
Feb 15, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jaredhirsch created this gist
Feb 15, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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).