Problem/Motivation
Currently the autoComplete() function returns a JsonResponse - even when the minimum number of characters has not been hit.
Since it is a JsonResponse and not a CacheableJsonResponse, those requests are still made against origin and are uncacheable.
Proposed resolution
Return a CacheableJsonResponse instead of a JsonResponse with a cache context of url.query_args.
Ideally, the this could also be tied to a cache tag that would be associated with the suggestion table.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | Screenshot from 2026-07-28 22-35-26.png | 608.04 KB | bkelly |
Issue fork suggestion-3593572
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jastraat commentedI also added an automated test for the new functionality. In order to run that test, I needed to add a number of other elements like configuration schema that were missing.
Comment #4
jastraat commentedComment #5
samlerner commentedI tested this, and it works for me. Here's the headers when I ran
curl -I "https://example.ddev.site/suggestion/autocomplete?q=foo"against a D11 site:And after this patch:
Note that
cache-controlchanges to be enabled, and there are additional headers for cache tags.Looks good to me!
Comment #6
samlerner commentedComment #7
bkelly commentedOh my gosh, my humble apologies, (renovating the house and didn't see all this action).
Now this sounds very interesting, I'll get up to speed with y'all tomorrow.
Thank you for your time.
- Bill Kelly
Comment #8
jastraat commentedBill do you have questions? Just checking in :)
Comment #9
bkelly commentedImpressive work, really.
Great job solving something that wasn't even on my radar and adding the extra trimmings, (tests, schema...). Most excellent.
I've set aside today to familiarize myself with the new git.drupalcode.org workflow, (or some Drupal fanboy will freak out).
- Bill Kelly
Comment #11
bkelly commentedHi Folks -
I think I've merged y'alls work into 4.1.x-dev. Since the new fancy Drupal CI doesn't appear to include all the individual commits I'm not sure yet.
Since I'm unfamiliar with the system I could have pooched this so I'm not sure if this statement applies, but as far as I'm concerned any CI system that doesn't include the branch history in a merge is fundamentally flawed, (or other words starting with "F". Grrrr...).
I'm going to review the merge and see about creating a new release.
Thank you for your time.
- Bill Kelly
Comment #12
jastraat commentedThanks Bill! Would you mind updating the contribution record for this issue too?
Comment #13
jastraat commentedUpdating to fixed since this was merged -
Comment #16
jastraat commentedHi Bill, could you please update the contribution record?
Comment #17
bkelly commentedHi jastraat -
I believe I succeeded. Thanks for all the great work.
-- Bill Kelly
Comment #18
jastraat commentedThanks! :)