API Reference / API Methods / Cache (browser only)
Jan. 16, 2019

Cache (browser only)

To avoid performing the same API calls twice, search results are stored in a cache that is tied to your JavaScript client and index objects. Whenever a call for a specific query (and filters) is made, we store the results in a local cache. If you ever call the exact same query again, we read the results from the cache instead of doing an API call.

This is particularly useful to avoid useless API calls when end users delete characters from their current query. It’s stored as a simple JavaScript object in memory, so the cache is automatically reset whenever the page is refreshed.

The cache isn’t automatically purged, nor can it be completely disabled. Instead, we provide the index.clearCache() (or client.clearCache() if you’re using the Search multiple indices method) that you can call to reset it.

Did you find this page helpful?

JavaScript