Problem/Motivation
Coffee module does an AJAX request to the backend on every page request for a user with access to Coffee. With a stock install of Drupal CMS the Coffee AJAX request actually takes longer and executes more database queries etc. than the main page request.
There are two kinds of sites where I think this would be a problem:
1. A very low traffic install of Drupal on a host that charges by traffic, e.g. Pantheon where CMS requests specifically (as opposed to static assets) can push you into a higher tier.
2. A site with lots of authenticated users and where a decent proportion of these have Coffee access, something like Drupal.org could be an example here e.g. I have some administrative access on Drupal.org but it's probably 0.01% of my traffic to d.o, and the Coffee AJAX request would happen for the other 99.9% reqeusts when it's not needed.
Because the coffee search is behind a link/keyboard shortcut, I think it should be fine to make the AJAX request when that search box is opened.
The AJAX request is blocking, so the search box opens after it's completed - this prevents someone typing before it's ready.
#2453585: [PP-1] Local Storage for Coffee is open but is blocked on cache invalidation. I will open a separate issue to discuss adding basic object and maybe http caching for the Coffee AJAX request which should help significantly reduce the time it takes for the AJAX request to complete once it's made.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | After.mp4 | 1022.18 KB | kumareshbaksi |
| #4 | Before.mp4 | 328.59 KB | kumareshbaksi |
Issue fork coffee-3494208
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
catchComment #4
kumareshbaksi commentedThe MR has been tested and works as expected. The unnecessary AJAX request on every page load is removed, and the request is now triggered only when the Coffee search box is opened.
This resolves performance concerns for both low-traffic and high-traffic sites while maintaining the same functionality and user experience.
Marking as RTBC and attaching screen recordings for reference.
Comment #5
catchComment #6
nebel54Thanks catch and kumareshbaksi! I checked the MR and did a local test, everything is looking good to me. Will merge it now to 2.x.
Comment #8
nebel54Comment #9
nebel54Comment #10
pameeela commented@nebel54 thanks for merging this! Any chance of getting a new tag before our Drupal CMS release on Jan 15? We're not able to use patches or dev versions in our stable release, so would have to remove Coffee from our release without a tag.
Comment #11
nebel54@pameeela - sure, I have created the release 2.0.1 now. Good luck with the Drupal CMS launch!
Comment #12
pameeela commentedThat's a relief, I got used to having it :) Thank you!