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

CommentFileSizeAuthor
#4 After.mp41022.18 KBkumareshbaksi
#4 Before.mp4328.59 KBkumareshbaksi

Issue fork coffee-3494208

Command icon 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

catch created an issue. See original summary.

catch’s picture

Status: Active » Needs review
kumareshbaksi’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new328.59 KB
new1022.18 KB

The 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.

catch’s picture

nebel54’s picture

Thanks 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.

  • nebel54 committed 81d771b1 on 2.x authored by catch
    Issue #3494208 by catch, kumareshbaksi: Get coffee data only when the...
nebel54’s picture

Status: Reviewed & tested by the community » Fixed
nebel54’s picture

pameeela’s picture

@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.

nebel54’s picture

@pameeela - sure, I have created the release 2.0.1 now. Good luck with the Drupal CMS launch!

pameeela’s picture

That's a relief, I got used to having it :) Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.