Skip to content

perf(get-component): cache acceptLanguageParser.parse results - #1480

Closed
ricardo-devis-agullo wants to merge 3 commits into
masterfrom
perf/cache-accept-language-parser
Closed

perf(get-component): cache acceptLanguageParser.parse results#1480
ricardo-devis-agullo wants to merge 3 commits into
masterfrom
perf/cache-accept-language-parser

Conversation

@ricardo-devis-agullo

Copy link
Copy Markdown
Collaborator

acceptLanguageParser.parse is called on every data-provider request with
the same Accept-Language header value. Since it's a pure function (same
input → same output), cache the result using the existing nice-cache instance
keyed by the raw header string.

This avoids repeated parsing of identical Accept-Language headers across
concurrent and sequential requests from the same browser.

ricardo-devis-agullo and others added 3 commits May 27, 2026 12:07
acceptLanguageParser.parse is called on every data-provider request with
the same Accept-Language header value. Since it's a pure function (same
input → same output), cache the result using the existing nice-cache instance
keyed by the raw header string.

This avoids repeated parsing of identical Accept-Language headers across
concurrent and sequential requests from the same browser.
@ricardo-devis-agullo

Copy link
Copy Markdown
Collaborator Author

Closing as superseded.

The original goal (avoid re-parsing the same Accept-Language header on every data-provider call) is already covered better on master by the lazy per-request getter introduced in the Jul 23 perf work (get acceptLanguage + parsedAcceptLanguage ??= in get-component.ts):

  • parse only if the data provider actually reads context.acceptLanguage
  • at most one parse per request

Cross-request caching of parsed headers (this PR’s approach via nice-cache) is a smaller incremental win and not worth rebasing/conflict-resolving on top of that. If we ever want process-wide caching later, it can be a fresh bounded-cache change on the getter — not this branch.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant