Can httr cache requests during a session?



I feel that this is a very easy question but I can't find anything on the web nor in the httr docs.

Basically, I have a GET call that request info from an API. Sometimes I might request the same information, i.e. the same query parameters but after another request.

my_GET <- function(url) {
GET(url = url) # extra args here

create_path <- function(path) {
complete_url <- modify_url(url = "whatever", path)


Is there a way for the third request to just retrieve the results from the first request? I think I can work out a "manual" version such as saving the results in a tempdir and checking manually but I think this might be taken care of by the httr package. Any ideas?


I'm not 100% sure what the answer is, but you might want to take a look at httr/cache.R (link below):

You might also want to check out the memoise package.

If a function is called multiple times with the same input, you can often speed things up by keeping a cache of known answers that it can retrieve.



Thanks, I will check them out.