Skip to content

CJM-115545: useServerInfoCache - Enables caching of server info and i…#127

Open
blfakir wants to merge 1 commit intoadobe:masterfrom
blfakir:serverinfocache
Open

CJM-115545: useServerInfoCache - Enables caching of server info and i…#127
blfakir wants to merge 1 commit intoadobe:masterfrom
blfakir:serverinfocache

Conversation

@blfakir
Copy link
Collaborator

@blfakir blfakir commented Oct 21, 2025

Description

Implements server info caching in client connection options.

  • Adds boolean option useServerInfoCache to enable caching of server info and installed packages.
  • Adds useServerInfoCacheTTL to control TTL of the cache (default 1 day).

Related Issue

  • CJM-115545 (link to the issue if available)

Motivation and Context

Reduces initial round-trips to fetch server info and installed packages, improving performance on repeated initializations.

How Has This Been Tested?

  • Unit tests run locally; all passed within existing thresholds.
  • Manual verification of caching behavior by toggling useServerInfoCache and observing fewer transport calls after first fetch.

Screenshots (if appropriate):

N/A

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@blfakir blfakir requested review from mkiki and obriard and removed request for obriard October 21, 2025 09:39
package.json Outdated
{
"name": "@adobe/acc-js-sdk",
"version": "1.1.61",
"version": "1.1.62",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you keep this to 1.1.61? I'll do the release with a separate PR

src/client.js Outdated
* @property {number} timeout - Can be set to change the HTTP call timeout. Value is passed in ms.
* @property {string} cacheRootKey - "default" or "none" - determine the prefix to use for the keys in the caches of schemas, options, etc.
* @property {string} instanceKey - an optional value to override the instance key which is used for the caches of schemas, options, etc.
* @property {boolean} useServerInfoCache - Enables caching of server info and installed packages. Defaults to false
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add useServerInfoCache for consistency?

src/client.js Outdated
this._options.entityCacheTTL = options.entityCacheTTL || 1000*300; // 5 mins
this._options.methodCacheTTL = options.methodCacheTTL || 1000*300; // 5 mins
this._options.optionCacheTTL = options.optionCacheTTL || 1000*300; // 5 mins
this._options.useServerInfoCacheTTL = options.useServerInfoCacheTTL || 1000*60*60*24; // 1 day
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you init useServerInfoCache for consistency?

src/client.js Outdated
const name = DomUtil.getAttributeAsString(pack, "name");
const fullName = `${namespace}:${name}`;
this._installedPackages[fullName] = fullName;
packagesArray.push({ namespace, name });
Copy link
Contributor

Choose a reason for hiding this comment

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

packagesArray is not used?

const useCache = this._useServerInfoCache && cachedPackages && cachedUserInfo && cachedLastPostUpgrade && cachedServerInfo;

if ( useCache) {
const sessionInfo = DomUtil.newDocument("sessionInfo");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason not to cache the whole XML document?

if ( useCache) {
const sessionInfo = DomUtil.newDocument("sessionInfo");
const sessionInfoRoot = sessionInfo.documentElement;
const serverInfoElement = sessionInfo.createElement('serverInfo');
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add try/catch around the this block of code and log a warning +
fallbakc to not using the cache if there's an execption?
That way if cache get corrupted, the SDK willl gracefully fall back to not using the cache

const crypto = require("crypto");

const makeKey = () => {
const a = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change identation (several occurrences)

@blfakir blfakir force-pushed the serverinfocache branch 2 times, most recently from 7e09e5f to 1143380 Compare October 24, 2025 11:45
</tbody>
</table>

pa No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

why "pa" ?

there is new line missing

src/client.js Outdated
exports.ConnectionParameters = ConnectionParameters;
})();
Copy link
Contributor

Choose a reason for hiding this comment

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

missing end of line

src/client.js Outdated
* @property {number} entityCacheTTL - The TTL (in milliseconds) after which cached XTK entities expire. Defaults to 5 minutes
* @property {number} methodCacheTTL - The TTL (in milliseconds) after which cached XTK methods expire. Defaults to 5 minutes
* @property {number} optionCacheTTL - The TTL (in milliseconds) after which cached XTK options expire. Defaults to 5 minutes
* @property {number} useServerInfoCacheTTL - The TTL (in milliseconds) for the server info cache. Defaults to 1 day
Copy link
Contributor

Choose a reason for hiding this comment

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

should be serverInfoCacheTTL instead of useServerInfoCacheTTL right?

@blfakir
Copy link
Collaborator Author

blfakir commented Jan 22, 2026

@obriard Done thx

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.

4 participants