I am trying to download some data from the url
below using the curl
-package. However, the first initial call is slow, but the subsequent calls are significantly faster. I have tested this on various R
sessions, and if I make a call on a different R
session, the unrelated R
session is also faster. So I expect that I am doing something wrong.
Below is a MWE of how I am using the curl
-package.
url <- "https://data-api.binance.vision/api/v3/klines?symbol=ETHUSDT&interval=1d&limit=1000&startTime=1702512000000&endTime=1719878400000"
handle <- curl::new_handle()
system.time(
{
curl::curl_fetch_memory(
url = url,
handle = handle
)
}
)
#> user system elapsed
#> 0.039 0.004 2.088
system.time(
{
curl::curl_fetch_memory(
url = url,
handle = handle
)
}
)
#> user system elapsed
#> 0.002 0.000 0.378
How can I setup the handle
such that it will be as fast as the subsequent calls?
Created on 2024-07-03 with reprex v2.1.0