function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Curtis ParisCurtis Paris 

Caching the Login Session & Server

The LoginResult object currently gives back a Session ID (getSessionId) and a server (getServerUrl).  The documentation mentions that for recurring access, you should cache the session ID and simply place that back onto the SOAP header.  But, it fails to mention the Server URL.

How constant is the Server URL?  Since it's possible to not be on the same server do I need to cache that as well?  And how safe is it to cache?

Once I have both the Session and the Server cached, is there a call I can make, prior to doing my other work, to verify that it is correct?  For example, will calling the getServerTimeStamp function validate my session?


You could cache the server URL for a given session, but in the future we could add or change server names, so do not cache the server URL for anything longer than the session.

Hi Curtis,

The server url has a one to one relationship with the user's instance.  This means that as a user you are "homed" on a particular server farm, indicated by the server url.  The server url will always be the same for a particular customer.  You can cache the server url as you would the session id.

As Benji suggests, the best practice here is to cache data for the duration of the session and not across sessions.  This will make your code more robust and cause less headaches if we do change the name of a particular server farm instance.