[Rd] Enable compression in download.file()

Jeroen Ooms jeroenoom@ @end|ng |rom gm@||@com
Thu Apr 3 11:13:44 CEST 2025


Comparing download times of base R and the curl package:

  url <- 'https://jeroen.github.io/data/nycflights13.json'
  tmp <- tempfile()
  system.time(download.file(url, tmp, quiet = F)
  system.time(curl::curl_download(url, tmp, quiet = F))

Because this is an uncompressed file, the gzipped download is about 7x faster.

For the solution see https://curl.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html :

> To aid applications not having to bother about what specific algorithms this particular libcurl build supports, libcurl allows a zero-length string to be set ("") to ask for an Accept-Encoding: header to be used that contains all built-in supported encodings.



More information about the R-devel mailing list