Skip to main content

Cache and storage

The SDK keeps controller responses in an internal in-memory LRU cache with TTL eviction for the life of the page. Nothing in this cache survives a page load. Configure storage separately when you want to persist prepared search IDs across pages:
The public cache object exposed in v2 has been removed. Cache behavior is controlled through cache in SdkConfig. The optional storage value is used only by the search prepare store.

Cache configuration

Controller responses stay in memory only. The SDK uses the configured StorageBackend to persist prepared search IDs so a later page can reuse them. Pass a backend such as localStorage, sessionStorage, or a custom implementation when you need cross-page prepare reuse.

StorageBackend

A storage backend persists prepared search IDs. It is any object matching this subset of the Storage interface:
Pass localStorage or sessionStorage when you want prepared search IDs to survive navigation within the browser:
For Node.js or SSR, pass an object that wraps your store:

Custom fetch

The SDK uses the global fetch by default. You can provide a custom fetch implementation for SSR, testing, or environments where fetch is not available:
The SDK also exports xhrFetch, an XMLHttpRequest-based fetch alternative for environments where fetch is blocked by ad blockers or browser extensions:

Singleton access

After initialization, access the SDK anywhere:

Technical details

  • Runtime: Browser (ESM) and Node.js with a custom fetch and storage
  • TypeScript: Full type definitions included
  • Dependencies: None
  • Bundle: Tree-shakeable ES modules
  • Caching: In-memory LRU cache with TTL for controller responses
  • Request deduplication: In-flight requests with the same parameters are deduplicated
  • Prepared search IDs: Optional storage backend with a five-minute default TTL

Next steps