Make a normal request for the resource
$ curl -si 'http://localhost:8080/myapp/tmp.json'
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Accept-Ranges: bytes
ETag: W/"43-1404927802000"
Last-Modified: Wed, 09 Jul 2014 17:43:22 GMT
Cache-Control: max-age=315619200
Expires: Tue, 09 Jul 2024 18:04:57 GMT
Content-Type: application/json
Content-Length: 43
Date: Wed, 09 Jul 2014 18:04:57 GMT
{
"first": "Colin"
"last": "MacDonald"
}
Grab the ETag from the response and send it in the 'If-none-match' header
$ curl -si -H 'If-none-match: W/"43-1404927802000"' 'http://localhost:8080/myapp/tmp.json'
HTTP/1.1 304 Not Modified
Server: Apache-Coyote/1.1
ETag: W/"43-1404927802000"
Date: Wed, 09 Jul 2014 18:05:10 GMT
Now update the timestamp on the file.
$ touch /usr/local/Cellar/tomcat/7.0.53/libexec/webapps/myapp/tmp.json
Then request it.
$ curl -si -H 'If-none-match: W/"43-1404927802000"' 'http://localhost:8080/myapp/tmp.json'
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Accept-Ranges: bytes
ETag: W/"43-1404929189000"
Last-Modified: Wed, 09 Jul 2014 18:06:29 GMT
Cache-Control: max-age=315619200
Expires: Tue, 09 Jul 2024 18:06:36 GMT
Content-Type: application/json
Content-Length: 43
Date: Wed, 09 Jul 2014 18:06:36 GMT
{
"first": "Colin"
"last": "MacDonald"
}
You get the full response, with the updated ETag header.
No comments:
Post a Comment