Skip to content

Commit

Permalink
Update example in overview section
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scavo authored Apr 26, 2017
1 parent b91df2b commit 26311ac
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,58 @@ $ echo $?
$ ls -1 $CACHE_DIR
1e6b844a49d1850b82feded72cf83ed7_content
1e6b844a49d1850b82feded72cf83ed7_headers
cget_log.txt
$ cat $CACHE_DIR/1e6b844a49d1850b82feded72cf83ed7_headers
HTTP/1.1 200 OK
Date: Sat, 29 Oct 2016 18:48:29 GMT
Date: Wed, 26 Apr 2017 16:29:44 GMT
Server: Apache
Last-Modified: Fri, 28 Oct 2016 19:11:49 GMT
ETag: "1f802b-252f7f2-53ff1a146e740"
Last-Modified: Tue, 25 Apr 2017 19:14:05 GMT
ETag: "299866f-54e0286fb789a"
Accept-Ranges: bytes
Content-Length: 38991858
Connection: close
Content-Length: 43615855
Content-Type: application/samlmetadata+xml

$ cat $CACHE_DIR/cget_log.txt
2017-04-26T16:29:44Z cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml
2017-04-26T16:30:09Z conditional_get received response code: 200
2017-04-26T16:30:10Z conditional_get writing cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content
2017-04-26T16:30:10Z conditional_get reading cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content
```

Assuming the resource doesn't change on the server, subsequent requests will return the cached resource. To bypass the network altogether, use the ``-C`` option:

```Shell
$ $BIN_DIR/cget.sh -C $url1 | wc -c
38991858
43615855
```

Of course the ``-C`` option will fail if the resource is not cached:

```Shell
$ $BIN_DIR/cget.sh -C $url2 2> /dev/tty
ERROR: conditional_get: resource not cached: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml
# illustrate "quiet failure mode"
$ $BIN_DIR/cget.sh -C $url2
$ echo $?
1
$ cat $CACHE_DIR/cget_log.txt | tail -n 2
2017-04-26T16:39:38Z cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml
2017-04-26T16:39:38Z conditional_get: ERROR: resource not cached: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml
```

OTOH, the ``-F`` option forces the return of a fresh resource from the server. If the resource is cached and unchanged on the server (304), such a request will fail, however:

```Shell
$ $BIN_DIR/cget.sh -F $url1 2> /dev/tty
ERROR: conditional_get: resource not modified: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml
# again illustrate "quiet failure mode"
$ $BIN_DIR/cget.sh -F $url1
$ echo $?
1
$ cat $CACHE_DIR/cget_log.txt | tail -n 2
2017-04-26T16:41:55Z conditional_get received response code: 304
2017-04-26T16:41:55Z conditional_get: ERROR: resource not modified: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml
```

The ``-F`` option will work on the other URL, however:

```Shell
$ $BIN_DIR/cget.sh -F $url2 > /dev/null
$ echo $?
0
Expand Down

0 comments on commit 26311ac

Please sign in to comment.