Skip to content

MENDELU/Fix dspace-customers 1083 R22: SSR cache keyed by origin and language - #1756

Open
jr-rk wants to merge 1 commit into
customer/mendelufrom
mendelu/fe-ssr-host-header-cache-key
Open

jr-rk wants to merge 1 commit into
customer/mendelufrom
mendelu/fe-ssr-host-header-cache-key

Conversation

@jr-rk

@jr-rk jr-rk commented Nov 26, 2026 •

Copy link
Copy Markdown

References

Port of dtq-dev-93 PR 1718 (commit fd7cd1c), the v9 port of dtq-dev PR 1669. dspace-customers issue 1083, finding R22.
In comparison with the source, the diff does not contain html-content.service.ts and spec - these files do not exist in this DSpace instance.

Description

The SSR page caches were keyed by req.url only, and the bot cache was read before the login check. Now the key holds origin, path and language, and the bot cache serves only anonymous requests.

Instructions for Reviewers

  • server.ts and new ssr-cache-key.util.ts: the same as the source, applied without conflict.
  • Not applicable: the static page part. mendelu has no static pages (html-content.service and static-page do not exist), so those files are left out.
  • The title differs from the source because the static page part does not apply.
  • Tests: ssr-cache-key.util.spec.ts (2 specs pass locally on Node 20). ESLint is clean on the changed files, npm run build:prod passes. Not tested on a running SSR server.

Checklist

  • My PR is created against the branch it ports to
  • My PR is small in size
  • My PR follows the code conventions and passes ESLint
  • My PR passes the relevant specs and includes new or updated specs
  • My PR includes details on how to test it
  • No new dependencies, no new configuration

…language

Port of dtq-dev-93 PR 1718 (commit fd7cd1c), the v9 port of dtq-dev
PR 1669. server.ts and ssr-cache-key.util(.spec).ts apply unchanged.
mendelu has no static pages (no html-content.service), so the static page
part of 1718 does not apply and is left out.
@jr-rk jr-rk self-assigned this Nov 26, 2026
@jr-rk
jr-rk requested a lite review from Copilot November 26, 2026 10:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A critical active finding shows the SSR cache key can serve localized HTML or REST data across different Accept-Language headers, causing incorrect language-specific responses.

1 open issue
What changed in this PR

Updates SSR page caching to isolate cached renders by request origin and language while preventing authenticated requests from receiving bot-cache entries.

Changes:

  • Adds a shared SSR cache-key utility using protocol, host, language cookie, and request URL.
  • Applies the new key to SSR cache reads and writes.
  • Restricts bot-cache reads to anonymous requests and adds focused unit tests.
File Description
src/​app/​shared/​ssr-cache-key.util.ts Defines the origin-, language-, and URL-aware SSR cache key.
src/​app/​shared/​ssr-cache-key.util.spec.ts Tests cache-key separation by language and request origin.
server.ts Uses the new cache key and prevents authenticated requests from reading the bot cache.

Review effort: Lite

* @param req current request
*/
export function getSsrCacheKey(req: Request): string {
return JSON.stringify([req.protocol, req.get('host'), req.cookies?.[LANG_COOKIE], req.url]);
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.

2 participants