Examples for 'httr::cache_info'


Compute caching information for a response.

Aliases: cache_info rerequest

Keywords:

### ** Examples

# Never cached, always causes redownload
r1 <- GET("https://www.google.com")
cache_info(r1)
<cache_info>  https://www.google.com/
  Cacheable:     TRUE
  Expires:       Mon, 11 Aug 2025 16:02:23 GMT <expired>
  Last-Modified: 
  Etag:          
r1$date
[1] "2025-08-11 16:02:23 GMT"
rerequest(r1)$date
[1] "2025-08-11 16:02:23 GMT"
# Expires in a year
r2 <- GET("https://www.google.com/images/srpr/logo11w.png")
cache_info(r2)
<cache_info>  https://www.google.com/images/srpr/logo11w.png
  Cacheable:     TRUE
  Expires:       Tue, 11 Aug 2026 16:02:24 GMT
  Last-Modified: Tue, 22 Oct 2019 18:30:00 GMT
  Etag:          
r2$date
[1] "2025-08-11 16:02:24 GMT"
rerequest(r2)$date
[1] "2025-08-11 16:02:24 GMT"
## Not run: 
##D # Has last-modified and etag, so does revalidation
##D r3 <- GET("http://httpbin.org/cache")
##D cache_info(r3)
##D r3$date
##D rerequest(r3)$date
##D 
##D # Expires after 5 seconds
##D r4 <- GET("http://httpbin.org/cache/5")
##D cache_info(r4)
##D r4$date
##D rerequest(r4)$date
##D Sys.sleep(5)
##D cache_info(r4)
##D rerequest(r4)$date
## End(Not run)

[Package httr version 1.4.7 Index]