This issue has been created
 
 
XWiki Platform / cid:jira-generated-image-avatar-b46bb87d-da08-4f7c-8281-964825560fca XWIKI-25009 Open

The localization translations REST resource sets no cache headers

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-08962d55-4cd5-4d6a-b10e-cd7843bce29c Manuel Leduc created this issue on 17/Sep/26 09:47
 
Summary: The localization translations REST resource sets no cache headers
Issue Type: cid:jira-generated-image-avatar-b46bb87d-da08-4f7c-8281-964825560fca Improvement
Affects Versions: 17.10.0-rc-1
Assignee: Unassigned
Components: Localization, REST
Created: 17/Sep/26 09:47
Labels: performance
Priority: cid:jira-generated-image-static-major-f5d2721f-6e0e-4683-9209-8f2545a9a5de Major
Reporter: Manuel Leduc
Description:

Context

TranslationsResource, in xwiki-platform-localization-rest-api, serves the translations consumed by the front-end localization resolver and by the xwiki-l10n RequireJS loader plugin. It is a plain @GET with no cache directive.

Actual

The resource sets no Cache-Control, Expires, ETag or Last-Modified header, so every front-end component that needs translations re-fetches them on every page view, even though it asks for the same keys in the same locale each time.

Expected

The response carries cache headers, so that a browser can reuse the translations it already holds instead of fetching them again on the next page view.

The result depends only on the wiki, the locale of the request context and the requested keys, all three of which are part of the request. It changes only when a translation bundle changes.

Suggested fix

Derive an ETag (or a Last-Modified) from the version of the translation bundles the answer was built from, and honour the conditional request, so that a repeat call costs a 304 instead of the full payload.

Mind the invalidation constraint when choosing between that and a plain max-age: an administrator who edits a Translations document expects the new values to show up, so a long max-age would keep serving stale translations, whereas a cheap revalidation would not.

Related: XWIKI-25008, which reduces the number of these requests; this issue makes each remaining one cheap on a repeat visit.