You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Widget Specific Instructions](#widget-specific-instructions)
24
+
-[Caching](#caching)
24
25
-[Compatibility](#compatibility)
25
26
-[Development](#development)
26
27
-[Help](#help)
@@ -636,6 +637,46 @@ search = instantsearch({
636
637
});
637
638
```
638
639
640
+
## Caching
641
+
642
+
There are two modes of caching:
643
+
644
+
1.**Server-side caching:**
645
+
646
+
To enable server-side caching, add a parameter called `useServerSideSearchCache: true` in the `server` configuration block of the typesense-instantsearch-adapter like this:
useServerSideSearchCache:true// <<< Add this to send use_cache as a query parameter instead of post body parameter
655
+
},
656
+
additionalSearchParameters: {...}
657
+
});
658
+
```
659
+
660
+
This will cause the adapter to add `?use_cache=true` as a URL query parameter to all search requests initiated by the adapter, which will then cause Typesense Server to enable server-side caching for these requests.
661
+
662
+
2.**Client-side caching:**
663
+
664
+
The adapter also has client-side caching enabled by default, to prevent unnecessary network calls to the server. TheTTLforthis client-side cache can be configured like this:
665
+
666
+
```javascript
667
+
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
668
+
server: {
669
+
apiKey: "...",
670
+
nearestNode: {...},
671
+
nodes: [...],
672
+
cacheSearchResultsForSeconds: 2 * 60 // <<< Add this to configure the TTL for client-side cache in the browser
0 commit comments