Hello,

you can also add a helper on the client side to throttle the requests,
e.g. with backbone/underscore [1] this looks like:


    searchBarKeyUp: _.throttle(function (e) {

      e.preventDefault();
      var $input = $(e.currentTarget);
      var val = $input.val();

      if (e.which == 13 || val.length > 2 || val == '') {

        this.searchValue = encodeURI(val);
        //
        this.setList();
      }
    },
    600)


[1] https://underscorejs.org/#throttle


Br,
Max
Am Mi., 7. Nov. 2018 um 14:32 Uhr schrieb Sebastian Zimmer
<sebastian.zim...@uni-koeln.de>:
>
> Hi,
>
> I'm looking for a way to increase the *perceived* performance of the REST API.
>
> On my web page there's a results list that is updated automatically when the 
> text content of an input field is changed. This means that on each keystroke 
> by the user, a GET request to the REST API api is sent to obtain the new 
> results list.
>
> One GET request takes about 800 ms, which is acceptable to me given the 
> complexity of the query and the amount of data.
>
> The problem is that when the user types faster than the queries are executed, 
> the app starts to respond very slowly, because there are now several requests 
> pending. BaseX seems to execute all of them in parallel and it may well take 
> up to 14 seconds until it returns the results of the most recent search query.
>
> Is there a way to tell BaseX to abort running queries (by a specific user) to 
> privilege the most recent query (of this user)? Could this be done with the 
> Jobs module? Or is there a better way to implement such a search?
>
> Best regards,
> Sebastian
>
> --
> Sebastian Zimmer
> sebastian.zim...@uni-koeln.de
>
> Cologne Center for eHumanities
> DH Center at the University of Cologne
> @CCeHum

Reply via email to