Repository navigation
Conversation
…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.
There was a problem hiding this comment.
🟡 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]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.tsandspec- these files do not exist in this DSpace instance.Description
The SSR page caches were keyed by
req.urlonly, 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.tsand newssr-cache-key.util.ts: the same as the source, applied without conflict.html-content.serviceandstatic-pagedo not exist), so those files are left out.ssr-cache-key.util.spec.ts(2 specs pass locally on Node 20). ESLint is clean on the changed files,npm run build:prodpasses. Not tested on a running SSR server.Checklist