Skip to content

Add frontend caching to vulnerabilities autocomplete

Heinrich Lee Yu requested to merge gfm-autocomplete-cache into master

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

  1. Go to any Markdown field like the new note form in an issue
  2. Type [vulnerability:<query term>
  3. 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.

Edited by Heinrich Lee Yu

Merge request reports

Loading