cache_info() gives details of cacheability of a response,
rerequest() re-performs the original request doing as little work
as possible (if not expired, returns response as is, or performs
revalidation if Etag or Last-Modified headers are present).
cache_info(r) rerequest(r)
| r | A response |
|---|
#> <cache_info> https://www.google.com/ #> Cacheable: TRUE #> Expires: Wed, 11 Mar 2020 04:09:55 GMT <expired> #> Last-Modified: #> Etag:r1$date#> [1] "2020-03-11 04:09:55 GMT"rerequest(r1)$date#> [1] "2020-03-11 04:09:55 GMT"#> <cache_info> https://www.google.com/images/srpr/logo11w.png #> Cacheable: TRUE #> Expires: Thu, 11 Mar 2021 04:09:55 GMT #> Last-Modified: Tue, 22 Oct 2019 18:30:00 GMT #> Etag:r2$date#> [1] "2020-03-11 04:09:55 GMT"rerequest(r2)$date#> [1] "2020-03-11 04:09:55 GMT"# Has last-modified and etag, so does revalidation r3 <- GET("http://httpbin.org/cache") cache_info(r3)#> <cache_info> http://httpbin.org/cache #> Cacheable: TRUE #> Last-Modified: Wed, 11 Mar 2020 04:09:55 GMT #> Etag: 71f70c1d621642b394b2c4a4cf77ce51r3$date#> [1] "2020-03-11 04:09:55 GMT"rerequest(r3)$date#> [1] "2020-03-11 04:09:55 GMT"