Skip to content

Backoffice Performance: Add inflight request deduplication to item data request managers#21767

Merged
madsrasmussen merged 4 commits intomainfrom
v17/improvement/items-inflight-request-cache
Feb 27, 2026
Merged

Backoffice Performance: Add inflight request deduplication to item data request managers#21767
madsrasmussen merged 4 commits intomainfrom
v17/improvement/items-inflight-request-cache

Conversation

@madsrasmussen
Copy link
Copy Markdown
Member

Adds an in-flight request cache to all item data request managers to prevent duplicate API calls when multiple components concurrently request the same items. This has currently only been implemented when requesting "detail" data.

Problem

When multiple UI components request the same item data simultaneously (e.g., during page load), each request independently hits the server — even if another request for the same IDs is already in-flight. This results in redundant API calls and unnecessary load.

Solution

Introduces UmbManagementApiInFlightRequestCache as a static per-manager cache that tracks in-progress requests. When a getItems() call is made, the manager now:

  1. Checks the data cache for already-resolved items
  2. Checks the inflight cache for items currently being fetched by another call
  3. Only requests items from the server that are neither cached nor in-flight

Concurrent calls with overlapping IDs will share the same server response rather than making separate requests.

Example

// Two concurrent calls happening at the same time:
Call A: getItems(['item-1', 'item-2', 'item-3'])
Call B: getItems(['item-2', 'item-3', 'item-4'])

// Before (2 full server requests):
Request 1: GET /item?id=item-1&id=item-2&id=item-3
Request 2: GET /item?id=item-2&id=item-3&id=item-4

// After (2 smaller requests, no overlap):
Request 1: GET /item?id=item-1&id=item-2&id=item-3  (from Call A)
Request 2: GET /item?id=item-4 (from Call B, item-2 & item-3 reused from Call A's inflight promise)

Testing Example

  • Set up multiple Document Pickers.
  • Pick documents that overlap between the pickers.
  • Notice in the network requests that we never request the same item twice.

Document Pickers with overlapping selection
Screenshot 2026-02-16 at 13 11 13

Network inspection
In total, we requested 6 items. Each picker requests only items that are not already cached or in-flight.

Screenshot 2026-02-16 at 13 10 53

Copilot AI review requested due to automatic review settings February 16, 2026 12:31
@madsrasmussen madsrasmussen added area/frontend category/performance Fixes for performance (generally cpu or memory) fixes labels Feb 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces in-flight request deduplication for all item data request managers in the Umbraco backoffice to prevent duplicate API calls when multiple UI components request the same items concurrently. The implementation adds a new UmbManagementApiInFlightRequestCache class and updates 20 item request managers to use it.

Changes:

  • Introduced UmbManagementApiInFlightRequestCache class to track in-progress requests per manager type
  • Modified UmbManagementApiItemDataRequestManager to deduplicate concurrent requests by checking inflight cache before making API calls
  • Updated all 20 item request managers to instantiate and provide a static inflight cache instance
  • Added comprehensive unit tests covering deduplication scenarios and edge cases

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

File Description
src/Umbraco.Web.UI.Client/src/packages/management-api/inflight-request/cache.ts New cache class for tracking in-flight requests with get/set/has/delete/clear operations
src/Umbraco.Web.UI.Client/src/packages/management-api/item/item-data.request-manager.ts Core deduplication logic: splits IDs into cached/inflight/new, creates deferred promises per item, resolves from shared batch responses
src/Umbraco.Web.UI.Client/src/packages/management-api/item/item-data.request-manager.test.ts Comprehensive test suite covering concurrent requests, cache behavior, and cleanup
src/Umbraco.Web.UI.Client/src/packages//repository/item/-item.server.request-manager.ts (20 files) Each item manager now has a static inflight cache instance passed to parent constructor

Copy link
Copy Markdown
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working nicely @madsrasmussen - I don't see any isuses.

I've tested with this setup:

image

There are 9 unique documents.

I see these requests:

https://localhost:44339/umbraco/management/api/v1/item/document?id=59cdd01f-dc65-486d-84f3-95b8361fcd4f&id=49ac6099-cf51-458b-b9a4-0c1f55dc7902&id=616d0f54-b8b0-450e-be0d-2ca4c06672a2&id=eab72f13-b22e-46d5-b270-9c196e49a53b&id=cdb2bf78-8292-44a3-bff8-5d18aee64078
https://localhost:44339/umbraco/management/api/v1/item/document?id=6374bda9-034a-4109-a837-72ed6a325f11&id=49b422c6-d5b8-486d-8a31-be39345178b2&id=4f0b7052-d854-43b5-bb7c-6c82af4d96d1
https://localhost:44339/umbraco/management/api/v1/item/document?id=cd99be2a-42b8-4dec-94fe-94a3d5d99d64

Which matches up:

  • Request 1, from property 3 - 5 items requested
  • Request 2, from property 1 - 3 items requested (Emm, Poormina, Jeavon)
  • Request 3, from property 2 - 1 item requested (Erica)

In comparison, with main - I see three requests each time for all items from the property.

@madsrasmussen
Copy link
Copy Markdown
Member Author

@AndyButland Thanks for testing. I will merge this so it can be included in 17.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/frontend category/performance Fixes for performance (generally cpu or memory) fixes release/17.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants