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 May 2, 2017
1 parent 08f9bf0 commit 64aa1e4
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ To illustrate, define a couple of HTTP resources, a cache, and a log file:
$ url1=http://md.incommon.org/InCommon/InCommon-metadata-preview.xml
$ url2=http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml
$ export CACHE_DIR=/tmp/http_cache
$ export LOG_FILE=$CACHE_DIR/cget_log.txt
$ touch $LOG_FILE
$ export LOG_FILE=/dev/tty
```

GET the first resource:

```Shell
$ $BIN_DIR/cget.sh $url1 > /dev/null
2017-05-02T13:24:57Z INFO cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml
2017-05-02T13:26:11Z INFO conditional_get received response code: 200
2017-05-02T13:26:11Z INFO conditional_get writing cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content
2017-05-02T13:26:12Z INFO conditional_get reading cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content
$ echo $?
0
$ ls -1 $CACHE_DIR
Expand All @@ -74,19 +77,15 @@ ETag: "299866f-54e0286fb789a"
Accept-Ranges: bytes
Content-Length: 43615855
Content-Type: application/samlmetadata+xml

$ cat $CACHE_DIR/cget_log.txt
2017-04-26T16:29:44Z INFO cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml
2017-04-26T16:30:09Z INFO conditional_get received response code: 200
2017-04-26T16:30:10Z INFO conditional_get writing cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content
2017-04-26T16:30:10Z INFO 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
43615855
2017-05-02T13:27:07Z INFO cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml
2017-05-02T13:27:07Z INFO conditional_get reading cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content
43765172
```

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

0 comments on commit 64aa1e4

Please sign in to comment.