verbs: Caching versions of httr verbs

Description Usage Arguments Value Examples

Description

Memory-caching versions of httr verbs that honour cache control headers. If you need more control over the caching, create your own with caching().

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15

Arguments

...

Arguments passed on to the corresponding httr verb.

Value

Result of original verb, but from a cache if applicable.

Examples

1
2
3
4
5
6
7
8
9
# Response header specifies two seconds of caching
cached_request <- function() {
  try(httc::GET("https://httpbin.org/cache/2"))
}

system.time(cached_request()) # First response from server
system.time(cached_request()) # Second uses cached result
Sys.sleep(2)
system.time(cached_request()) # Re-requested from server

mikmart/httc documentation built on Dec. 21, 2021, 6:57 p.m.