Add frontend caching to vulnerabilities autocomplete
What does this MR do and why?
Caches backend responses per search term so we don't make repeated requests to the backend for the same search term.
This is similar to the caching described in https://github.com/ichord/At.js/wiki/How-to-use-remoteFilter#caching-example
For context, my plan is to introduce backend filtering for the @
autocomplete and I think frontend caching would be useful since it's common to search for the same thing multiple times like when one does: "@xxx
can you review this? /assign_reviewer @xxx
".
So I thought it would be good to have this generic for all GFM autocompletes with backend filtering. Right now, only vulnerabilities use backend filtering.
The tradeoff here is that the results may be stale but this is on par with other autocompletes like labels, etc.. that don't have backend filtering. We actually load all the data upfront and cache it until the page is refreshed.
How to set up and validate locally
- Go to any Markdown field like the new note form in an issue
- Type
[vulnerability:<query term>
- Try changing the query term and it should make a request to the backend. When the term is something that was already requested, it should not make a request again until the page is refreshed.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.