Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Bogdan1988 CreditAttribution: Bogdan1988 commentedI also had this issue with taxonomy autocomplete widget and this feature seems to be very useful, Thanks!
Comment #1.0
anpolimusreduse -> reduce
Comment #2
oknateSounds 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.
Comment #2.0
oknategrammar rebuild
Comment #3
Chris CharltonDefinitely a good idea, especially for initial/low character lookups.
Comment #4
anpolimusChris, will you have tine to review my patch?
Comment #5
Chris Charlton@anpolimus, I will slate a test in my next dev sprint.