Get coffee data only when the search box is opened

Created on 16 December 2024, 3 days ago

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.

📌 Local Storage for Coffee Needs review 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

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024