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: Mon, 17 Aug 2020 22:22:28 GMT <expired> #> Last-Modified: #> Etag:r1$date#> [1] "2020-08-17 22:22:28 GMT"rerequest(r1)$date#> [1] "2020-08-17 22:22:28 GMT"#> <cache_info> https://www.google.com/images/srpr/logo11w.png #> Cacheable: TRUE #> Expires: Tue, 17 Aug 2021 22:22:28 GMT #> Last-Modified: Tue, 22 Oct 2019 18:30:00 GMT #> Etag:r2$date#> [1] "2020-08-17 22:22:28 GMT"rerequest(r2)$date#> [1] "2020-08-17 22:22:28 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: Mon, 17 Aug 2020 22:22:28 GMT #> Etag: bf59ee4905f34839b5ab490c0140c700r3$date#> [1] "2020-08-17 22:22:28 GMT"rerequest(r3)$date#> [1] "2020-08-17 22:22:28 GMT"