storage persists prepared search IDs, not controller responses, so a later page can reuse the prepare step.
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 thecache option at SDK initialization:
The SDK does not select a storage backend automatically. Pass
storage: localStorage, storage: sessionStorage, or a custom backend when you need prepared search IDs to survive navigation.
Storage backends
A storage backend is any object matching a subset of theStorage interface:
Browser storage
Node.js (memory store)
For SSR or build scripts, pass an in-memory store:sessionStorage
UsesessionStorage when you want prepared search IDs scoped to the current tab. The SDK still keeps controller responses in memory only:
Cache invalidation
The SDK does not expose a public cache invalidation API. To clear cached data, reset the SDK singleton or dispose individual controllers:Search cache
Thesearch 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.
prepare() call returns { search_id } for observability. Reuse is automatic within the page from memory, and across pages when you configure storage. Prepared search ID entries expire after five minutes by default.
Custom fetch
The SDK uses the globalfetch 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
You can pass any function matching theFetchFn signature. 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.
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.