simple caching of mocked HTTP responses, hooking into webmockr for the HTTP request matching

the need

  • vcr is meant really for testing, or sort of script use. i don’t think it fits well into a use case where another pkg wants to cache responses
  • memoise seems close-ish but doesn’t fit needs, e.g., no expiry, not specific to HTTP requests, etc.
  • we need something specific to HTTP requests, that allows easy expiration handling, a few different caching location options, works across HTTP clients, xxx

brainstorming

  • use webmockr to match requests (works with crul and httr, maybe curl soon)
  • possibly match on, and expire based on headers: Cache-Control, Age, Last-Modified, ETag, Expires (see [ruby’s faraday-http-cache])
  • caching backends: probably all binary to save disk space since most likely we don’t need users to be able to look at plain text of caches
  • expiration: set a time to expire. if set to 2019-03-08 00:00:00 and it’s 2019-03-07 23:00:00, then 1 hr from now the cache will expire, and a new real HTTP request will need to be made (i.e., the cache will be deleted)

how though?

without webmiddens

with webmiddens, make a midden object first

first request is a real HTTP request

second request uses the cached response from the first request

list cached items

Meta

ropensci_footer