I have noticed, that output of taxonomy autocomplete dont have cache headers.
When user try to find taxonomy term name he often in puts equal data in autocomplete field.

For example, I'm very often write "test" word and then delete some symbols and try another word.
DB at that time receive different queries with like:
t
te
tes
test
tes
te
ter
terr

As You can see there are many equal requests to the backend in little period of time.
I'm proposing to make return of the function like this:

 drupal_add_http_header('Cache-Control', 'public, max-age=' . variable_get('cache_lifetime', 300));
 drupal_json_output($term_matches);
 drupal_exit();

In this case we will reduce requests count to db storage during autocomplete action.

Comments

Bogdan1988’s picture

I also had this issue with taxonomy autocomplete widget and this feature seems to be very useful, Thanks!

anpolimus’s picture

Issue summary: View changes

reduse -> reduce

oknate’s picture

Sounds like a good feature.

I can imagine some cases where having the data cached too long would be an issue. But generally, for two and three letter combinations, caching would improve performance.

oknate’s picture

Issue summary: View changes

grammar rebuild

Chris Charlton’s picture

Issue summary: View changes

Definitely a good idea, especially for initial/low character lookups.

anpolimus’s picture

Chris, will you have tine to review my patch?

Chris Charlton’s picture

@anpolimus, I will slate a test in my next dev sprint.