httpcache: Query Cache for HTTP Clients
In order to improve performance for HTTP API clients,
provides simple tools for caching and invalidating cache. It includes the
HTTP verb functions
DELETE, which are drop-in
replacements for those in the httr package.
These functions are cache-aware and provide default settings
for cache invalidation suitable for RESTful APIs; the package also
enables custom cache-management strategies. Finally,
a basic logging framework to facilitate the measurement of HTTP request
time and cache performance.
httpcache can be installed from CRAN with
The pre-release version of the package can be pulled from GitHub using the devtools package:
# install.packages("devtools") devtools::install_github("nealrichardson/httpcache")
httpcache is as simple as loading the package in your interactive session or script instead of
httr, or, in package development, importing the HTTP verb functions from
GET() responses are added to the local query cache;
DELETE() requests trigger cache invalidation on the associated resources. You can override that default cache invalidation, and you can command the invalidation explicitly, with the invalidation functions
clearCache() wipes the cache completely.
vignette("httpcache") for examples of the HTTP cache in practice.
The repository includes a Makefile to facilitate some common tasks.
$ make test. Requires the httptest package. You can also specify a specific test file or files to run by adding a "file=" argument, like
$ make test file=logging.
test_package will do a regular-expression pattern match within the file names. See its documentation in the testthat package.
$ make doc. Requires the roxygen2 package.