Typeahead.js: How to disable search cache

Created on 27 May 2016  路  2Comments  路  Source: twitter/typeahead.js

Somehow typeahead is caching results and if something changes in my database it won't search unless I use a totally different term. This results in confusing results and reloading the web page is needed to make things work again.

Most helpful comment

This option is not documented but it's working for me, when you initialise Bloodhound, remote can have cache: false. Like this:

var items = new Bloodhound({
  datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  remote: {
    url: '/items/search?q=%QUERY',
    wildcard: '%QUERY',
    cache: false
  }
});

i hope that helps

All 2 comments

This option is not documented but it's working for me, when you initialise Bloodhound, remote can have cache: false. Like this:

var items = new Bloodhound({
  datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  remote: {
    url: '/items/search?q=%QUERY',
    wildcard: '%QUERY',
    cache: false
  }
});

i hope that helps

Thanks, now it works!

Was this page helpful?
0 / 5 - 0 ratings