caching: Create a function that honours HTTP caching headers

Description Usage Arguments Value See Also Examples

View source: R/caching.R

Description

Create a function that honours HTTP caching headers

Usage

1
caching(f, cache = cachem::cache_mem())

Arguments

f

A function that returns an httr::response.

cache

A cache object to control caching. See cachem::cache_mem().

Value

f with the response cached according to httr::cache_info(). The given cache object is available in the "cache" attribute.

See Also

Pre-wrapped httr verbs.

Examples

1
2
3
4
5
# Use a disk cache for persistent caching across sessions
disk_cached_get <- caching(httr::GET, cachem::cache_disk())

# Inspect the cache object
str(attr(disk_cached_get, "cache")$info())

mikmart/httc documentation built on Dec. 21, 2021, 6:57 p.m.