Hi everyone! I have a question about best practice...
# help
m
Hi everyone! I have a question about best practices. I have a typeahead input on my website. When the user types in, I make a query to get him a list of cities. Right now, I make a query every 500ms, but I don't know if it can be too much for my backend. My question is, what would be the best practice for this? Limit to a query every second? thanks!
n
Hello @Manuel Coffin! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
o
Hi To avoid a huge cost on your backend, you can limit requests with 3 characters minimum. So if the input length is less than 3, you don't start to find anything.
n
manuelcoffin (2022-04-07)
m
Yes ok that seems a good idea, thanks! I was also thinking maybe caching results from previous requests in local storage for like an hour or something, but maybe that's overkill...
o
You can, it optimizes a little more