#community-help

Improving Documentation for 'cacheSearchResultsForSeconds' Function

TLDR Edson suggested that 'cacheSearchResultsForSeconds' function should be included in official documentation. CaptainCodeman shared insights on using caching mechanisms for improving performance. Jason agreed and provided useful details about client-side and server-side caching options in Typesense.

Powered by Struct AI

1

13
23mo
Solved
Join the chat
Jan 27, 2022 (23 months ago)
Edson
Photo of md5-73ed38073601fcb89b49414b8b2d65e9
Edson
05:38 PM
Suggestion: document the use 'cacheSearchResultsForSeconds'. It is very useful and isn't mentioned in the official docs. I only knew it existed because it was available in the instant search github example. The only other reference to it is at https://giters.com/typesense/typesense-js/issues/52 . Official docs at the moment only discuss server-side caching. I considered editing the docs myself, but wasn't sure where to place it.
CaptainCodeman
Photo of md5-d3a4ca49ba4aeb3b9d0cb7d846eb0989
CaptainCodeman
05:46 PM
I’ve been experimenting with having my app proxy the requests to typesense - that way I can cache things there if I want (so the same search results are available to different visitors) and it also moves the query formulation / result translation code away from the client so not as much code + data has to go over the wire.
05:49
CaptainCodeman
05:49 PM
For an individual user, I use normal http headers / 304 response to cache results via the browser rather than having to create any specific cache mechanism in the client app
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:55 PM
Edson Yeah, I've been meaning to add client-specific docs to the README... For now, I just point to the Configuration class from the README to learn about all available options.
05:56
Jason
05:56 PM
CaptainCodeman There's actually both client-side caching and also server-side caching if needed in Typesense
05:56
Jason
05:56 PM
There's the use_cache and cache_ttl search parameters: https://typesense.org/docs/0.22.1/api/documents.html#caching-parameters
CaptainCodeman
Photo of md5-d3a4ca49ba4aeb3b9d0cb7d846eb0989
CaptainCodeman
05:56 PM
Yes, I’ve been using the use_cache option as well
06:06
CaptainCodeman
06:06 PM
my thinking is to have each browser re-use matching results when it can (local browser cache), have results re-used between users in the same area when possible (via CDN) and then have Typesense cache things too. It all seems to work well and should scale.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:08 PM
Nice! Cache all the way!
CaptainCodeman
Photo of md5-d3a4ca49ba4aeb3b9d0cb7d846eb0989
CaptainCodeman
06:09 PM
I’m so cheap - anything to save a $! 😄
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:09 PM
But caching improves performance as well! So improves UX for users 🙂
06:10
Jason
06:10 PM
As they say, resource constraints actually help build good products!
CaptainCodeman
Photo of md5-d3a4ca49ba4aeb3b9d0cb7d846eb0989
CaptainCodeman
06:10 PM
Yes, it does make everything nice and zippy. Honestly, I’m just so happy how well it’s working I can’t wait to launch the site that’s going to use it

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community

Similar Threads

Debugging Search Issue with Typesense Server Caching

Jameshwart reported experiencing caching issues with typesense server, despite the server's default setting of not caching. Through troubleshooting steps with Kishore Nallan, they were able to confirm an issue with the Typesense Javascript client and resolved it by adding `cacheSearchResultsForSeconds: 0` after `apiKey` in the initialisation. Laura also participated in discussion, learning about server and client level caching.

66
4mo
Solved

Enhancing Typesense-JS For Improved Cache Management

Jordan requested a way to clear the cache in 'typesense-js' when a new document is added. Jason recommended a work-around and supported Jordan's idea to add a 'clearCache' method. Jordan then submitted a PR for this implementation.

1

10
16mo
Solved

Discussing `use_cache` and `cacheSearchResultsForSeconds` Options

Aljosa wanted a confirmation for a technical issue and Jason suggested to use `use_cache` for both. Proposed updates were given to check if their issue resolves. Aljosa agreed to test out the proposed solution.

2

12
23mo

Troubleshooting Issues with DocSearch Hits and Scraper Configuration

Rubai encountered issues with search result priorities and ellipsis. Jason helped debug the issue and suggested using different versions of typesense-docsearch.js, updating initialization parameters, and running the scraper on a Linux-based environment. The issues related to hits structure and scraper configuration were resolved.

7

131
8mo
Solved

Phrase Search Relevancy and Weights Fix

Jan reported an issue with phrase search relevancy using Typesense Instantsearch Adapter. The problem occurred when searching phrases with double quotes. The team identified the issue to be related to weights and implemented a fix, improving the search results.

6

111
8mo
Solved