Skip to main content
The SDK automatically caches requests in memory to minimize API calls and improve performance. Cache persistence is optional and backed by a StorageBackend such as localStorage.

Request deduplication

When multiple controllers request the same data, the SDK deduplicates in-flight requests and reuses cached results:

Cache configuration

Control cache behavior with the cache option at SDK initialization:
In the browser, localStorage is used automatically when a StorageBackend is available. Pass storage: localStorage or a custom object.

Storage backends

A storage backend is any object matching a subset of the Storage interface:

Browser (localStorage)

Node.js (memory store)

For SSR or build scripts, pass an in-memory store:

sessionStorage

Swap localStorage for sessionStorage to keep cached data only while the tab is open:

Cache invalidation

The SDK does not expose a public cache invalidation API. To clear cached data, reset the SDK singleton or dispose individual controllers:
For the most common case, changing controller parameters (for example, a new page or filter) naturally produces a new cache key.

Search cache

The search controller uses the prepare endpoint to cache expensive work. get() automatically prepares the query when needed and retries a 425 response until results are ready.
When you pass a searchId, the server maintains the prepared state for a short window:

Custom fetch

The SDK uses the global fetch by default. Provide a custom implementation via the fetch option for SSR runtimes, testing, or environments where fetch is unavailable or blocked:

xhrFetch (browser fallback)

xhrFetch is an XMLHttpRequest-based fetch shipped with the SDK. Use it when ad blockers, browser extensions, or restrictive network policies intercept fetch calls:

Custom fetch

Any function matching the FetchFn signature can be passed. Common uses:
  • SSR / Node: inject a Node-compatible fetch on older runtimes.
  • Testing: stub responses without intercepting global fetch.
  • Instrumentation: add tracing or auth headers around the request.
The SDK handles abort signals and error classification on top of whatever fetch returns. Your adapter only needs to issue the request and return a Response.

Next steps

Performance

Learn performance optimization techniques.

Best practices

Review SDK best practices and common pitfalls.