Enable caching
ts
const api = createClient({ baseUrl: "https://api.example.com", cache: { ttl: 60_000, max: 500 },});Options
ttlDefault30000numberMilliseconds an entry stays fresh.maxDefault100numberEntries kept before the least recently used is evicted.keyDefaulturl.href(url: URL) => stringBuilds the cache key for a request.
| Option | Type | Default |
|---|---|---|
ttlMilliseconds an entry stays fresh. | number | 30000 |
maxEntries kept before the least recently used is evicted. | number | 100 |
keyBuilds the cache key for a request. | (url: URL) => string | url.href |
Invalidation
Call api.cache.delete(path) after a write, or api.cache.clear() to drop everything.