Using jQuery Autocomplete, according to the docs you have to do the following to cache:
<script>
$(function() {
var cache = {},
lastXhr;
$( "#birds" ).autocomplete({
minLength: 2,
source: function( request, response ) {
var term = request.term;
if ( term in cache ) {
response( cache[ term ] );
return;
}
lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) {
cache[ term ] = data;
if ( xhr === lastXhr ) {
response( data );
}
});
}
});
});
</script>
Didn’t there used to be an option to cache? Thanks
Caching for jQueryUI autocomplete was never an option.
There was a
cacheLengthoption for jQuery autocomplete (Jörn Zaefferer’s now deprecated autocomplete plugin).In the migration guide from autocomplete –> jQueryUI autocomplete, Jörn mentions this:
If you are using the caching implementation frequently, you could wrap the functionality in another plugin that encapsulates it.