DocumentationBuild. Deploy. Operate.
DocsDeployment

API Acceleration

On this page 9 sections

Follow these steps to serve signed JSON API responses through QSCS, reuse eligible results across nodes and deliver browser deltas. The examples use app.example.com for login and api.example.com for the API.

Backend: any language. Return ordinary HTTP/JSON from your existing application and enforce account permissions through trusted QSCS identity headers. The examples using qscs below are browser JavaScript, not backend code.

Native and server-to-server clients can make signed HTTP requests using Authentication & Signing. Start with ordinary JSON responses. Do not send delta or stream negotiation headers until your client implements the corresponding decoder and protocol; the packaged helpers rely on browser APIs.

1. Configure the API origin

  1. In Infrastructure, open your domain and choose Add origin or Edit settings.
  2. Enter the API hostname and its backend address, such as 127.0.0.1:8081 or https://backend.example.com. The address must be reachable from the domain’s master node. See Configuring Origins.
  3. Enable Require a signed identity and Proxy every request, then save. API delta delivery uses the default Delta=all policy.
  4. Return successful reads as HTTP 200 with Content-Type: application/json or an application/*+json media type. Keep the appropriate privacy headers, including Cache-Control: no-store for account data.

Complete the gated identity integration on the login application. Authorize each API request against the verified account subject; an account ID supplied in the URL is not authorization.

2. Add the federation relationship

For a same-origin API, skip this step and the federated response-cache settings below. You can still use the browser delta adapter.

  1. Under Infrastructure → Manage domain → Federated Domain Trust, choose Add trust.
  2. Choose whether this domain issues or accepts identities, select its local origin, then select the other origin. For this example, app.example.com issues identities accepted by api.example.com. Both origins must belong to your account and require signed identity.
  3. Enter the Allowed paths, for example /api/reports/. Prefixes match paths starting with that text; include the trailing slash to limit access to a subtree.
  4. Leave Identity binding lifetime at 60 seconds unless a different authorization refresh interval is required. Configure response caching in the next step.
  5. Save, then check the trust flow for Applied on all nodes. The console distributes both sides of the policy automatically.

The browser identity SDK discovers permitted API recipients automatically. Use __qscs_issuer=app.example.com in the request URL to select the issuer when needed. Keep the public hostname, path and query unchanged through reverse proxies so request signatures remain valid.

3. Choose response caching

Open the receiving domain, find the API origin under Origins, and choose API settings for the relevant issuer and paths. Identity-dependent controls are unavailable until both origins require signed identity and their trust relationship is enabled. Enable response caching only for read endpoints whose complete URL and verified account determine the response. Put representation choices such as language or report filters in the URL and validate them in the API.

SettingUse it to
API BoostReturn saved JSON immediately and refresh it in the background. Enable this for reports or dashboards where an older first result is acceptable. It selects Until invalidated storage.
Until invalidated (default)Keep reusing the saved response. Without API Boost, invalidate it after source data changes; there is no background refresh.
TimedReuse a response for the configured seconds. After expiry, the next request waits for a new backend response.
DisabledFetch a backend response on every request while retaining negotiated browser deltas.

Enable API Boost

Configure individual endpoints

  1. Under the API origin’s API settings, find the trusted identity issuer. Edit Default for allowed paths to set the fallback policy.
  2. Choose Add endpoint and enter a path prefix within the trust’s allowed paths, such as /api/reports/.
  3. Choose response caching, API Boost, the background refresh interval and the discovered dataset inactivity timeout for this endpoint. Save and check the node acknowledgements.
  4. Use Add endpoint again for other endpoints. Each listed rule has its own Edit and Remove actions.

The longest matching path prefix wins. For example, /api/reports/live/ can disable caching while /api/reports/ uses Boost with a 30-minute refresh interval. Other trusted paths use the default. Prefixes are literal: use a trailing slash when the rule should cover a directory. Query strings do not select a rule; different complete URLs still have separate cached responses.

Removing an endpoint rule leaves the route and identity permissions in place. Its requests use the next matching broader rule or the default. Rules cannot grant access outside the trust’s allowed paths. Changing a path or caching mode invalidates saved responses for that trust; adjusting only a refresh interval keeps them warm. Invalidate responses clears eligibility for all endpoints in the selected trust.

API Boost is included with Enterprise (£300 per month). Existing paid subscriptions keep their agreed access. On Free, start a one-time 30-day trial from your API settings or Billing. The trial starts when you choose it, with no payment method required. Nodes, domains and origins are unlimited on every plan. Your routes remain available after the trial; only API Boost expires. Overview shows the time remaining, and reminders go to your registered email 7 days and 24 hours before expiry. To keep Boost afterwards, upgrade to Dev in your billing console to enable it. API response caching, JSON delta delivery and cryptographic identity management are available on every plan.

Turn on API Boost, save and check the node acknowledgements. New sessions for the same verified account can reuse state replicated within the API’s domain. Set Background refresh interval for this API policy. The default is 120 seconds; choose between 10 seconds and 24 hours. After an authorised call discovers a dataset, the application-side node refreshes it in the background, including while the browser is closed. The interval schedules work; busy workers or backend failures can delay completion. Changing the interval preserves saved state. Use qscs.fetch() to read the refreshed result on your next request, or qscs.subscribe() below to receive changes over an open connection.

Choose the interval to match how quickly the API must reflect source changes and how expensive a refresh is. For expensive reporting APIs, 10–15 minutes may be appropriate if that freshness is acceptable. Keep faster-changing APIs on shorter intervals. This interval controls revalidation, not retention: saved state remains eligible until invalidated or evicted for capacity. Identity and authorisation checks still run independently.

Discovered dataset inactivity timeout defaults to 48 hours and can be set from 1 to 8,760 hours in API Boost settings, independently for the default policy and each endpoint rule. Only authorised client calls count as activity; refresh jobs and replicated responses do not extend the timeout. On QSCS 4.3.9 or newer, unused datasets stop refreshing and their local cached responses are removed. The next authorised call discovers them again. Existing datasets receive one recorded grace period when upgrading; restarts do not reset it. This setting does not remove domain history, delivery queues or configured endpoint rules. Check node acknowledgements after saving; older nodes need an update to enforce inactivity expiry.

  • Use complete JSON objects or arrays. Response capacity and temporary processing allowances scale with the node’s memory budget, including container limits. Large cached responses can be delivered as full JSON when they exceed the browser’s delta baseline limits. Avoid cookies, bearer credentials, range or conditional requests, encoded responses, Set-Cookie and unsafe Vary responses. Ineligible requests use the live path.
  • Use the default browser fetch cache mode for Boost reads; private responses already carry Cache-Control: no-store. Fetch modes no-store, reload and no-cache can send revalidation headers that bypass the immediate cached response. For a request that must wait for upstream validation, send Cache-Control: no-cache. Leave Boost disabled for workflows requiring current source data on every request.
  • When permissions or source data change, use Invalidate responses under the receiving origin’s API settings for that issuer and path scope and check acknowledgements. Writes do not automatically invalidate responses. Apply permission changes to the identity policy as well; do not rely on background refresh for immediate revocation.

Cached state remains subject to node capacity and persistence. Every hit still requires a valid signed identity. Browser-facing account responses retain no-store; the explicit node-cache policy is separate.

4. Make an API request

The qscs-bootstrap package installs the browser helpers in /opt/qscs/helpers alongside the matching WASM runtime. With browser navigation enabled (the default), Core injects the qscs client into eligible HTML pages and serves its files directly. If you use a reverse proxy, route /.qscs/helpers/ and /.qscs/browser/ through QSCS. No source snapshot, copied adapter or application-hosted WASM file is required.

If you disable browser navigation, load /.qscs/helpers/client.js from your application before using the client. After completing your identity session, make a signed JSON request:

Browser JavaScript — signed JSON request:

await qscs.ready;
const response = await qscs.fetch(
  'https://api.example.com/api/reports/summary?range=7d'
);
if (!response.ok) throw new Error('Report request was not accepted');
render(await response.json());

The helper discovers configured recipient trust, adds the issuer selector, negotiates deltas and returns a normal Response containing complete JSON. Same-origin calls can use a relative URL. Keep URLs stable; every path, query and identity has its own baseline. Full responses are used when no suitable baseline or decoder is available.

Receive live API updates

Enable API Boost for the receiving endpoint. Subscribe using the same URL:

Browser JavaScript — live updates:

const updates = qscs.subscribe(
  'https://api.example.com/api/reports/summary?range=7d',
  {
    onData(report) { render(report); },
    onError(error) { showReportError(error.message); }
  }
);

// When leaving this view:
updates.close();

A warm node sends its saved JSON immediately and keeps the connection open for updates. Changes received from an upstream refresh or a peer are delivered over that connection. The helper checks and reconstructs supported deltas, renews the connection with fresh signatures, and resumes without resending an unchanged baseline. A cold cache first returns its ordinary JSON response.

The endpoint’s Background refresh interval still controls upstream queries. Changes become visible when QSCS receives newer state; streaming does not observe database writes directly. Subscribers to the same eligible cache key share the existing refresh scheduling. Configure a shorter interval only when the backend can support it.

Subscriptions are bound to the verified account, issuer, path and policy. Access is checked during delivery; connections close when their binding expires or policy changes. Federated revocation follows the configured identity-binding lifetime and replication. The browser renews its signed connection approximately every 20 seconds. Never use a long-lived connection to extend expired authorization.

Pass an AbortSignal as signal to tie a subscription to a view. The packaged session controller closes subscriptions on logout or account changes. If you manage authentication yourself, call qscs.clear() before changing identity. A subscription stops on 401 or 403; use the issuer account check from the identity guide before deciding whether the user must sign in again.

The helper bounds concurrent streams per API origin and queues additional subscriptions. Use HTTP/2 at your public proxy for dashboards with concurrent API requests. Preserve streaming response delivery, disable buffering for text/event-stream, and allow heartbeats through. Ordinary JSON delivery remains available where a node or endpoint does not offer streaming.

5. Preserve CORS headers

CORS applies to cross-origin requests made by browsers, regardless of your backend language. Native and server clients still need valid signatures and authorization. If a reverse proxy handles OPTIONS or replaces CORS headers, allow GET preflights with these request headers:

Cache-Control, Content-Type, X-QSCS-Client-Uuid, X-QSCS-Ts, X-QSCS-Nonce, X-QSCS-Sig, X-QSCS-Delta, X-QSCS-Base-Hash, X-QSCS-Stream, X-QSCS-Stream-Delta, X-QSCS-Stream-Base

Expose these response headers to JavaScript:

X-QSCS-Mode, X-QSCS-Encoding, X-QSCS-Wire-Bytes, X-QSCS-Payload-Bytes, X-QSCS-Cache, X-QSCS-Stream

QSCS supplies the signature and delta CORS headers. Keep one consistent Access-Control-Allow-Origin policy at the public edge and do not transform encoded delta bodies. Also expose X-QSCS-TTL-Remaining, X-QSCS-Cache-Age and X-QSCS-Cache-Mode if your application reads those optional diagnostics.

6. Verify the result

  1. Request the same authorized URL twice. Await qscs.ready and confirm later negotiated requests include X-QSCS-Delta: 2 and X-QSCS-Base-Hash. A legacy decoder negotiates version 1 automatically.
  2. Change a small part of the JSON and repeat the request. Compare the reconstructed result with the backend response. Full responses during initial warm-up or when a delta would be larger are expected.
  3. Change the query or account and confirm that the client receives a full baseline without reusing another account’s data.
  4. For node caching, check X-QSCS-Cache: HIT and backend request logs. With Boost, also check X-QSCS-Cache-Mode: api-boost and X-QSCS-Cache-Age.
  5. Test Invalidate responses. After nodes acknowledge the policy, the next matching request must obtain fresh data.
Network responseExpected result
Full JSONThe adapter returns JSON and retains an eligible baseline.
incremental, application/x-qscs-delta, X-QSCS-Encoding: base64The adapter decodes and returns complete JSON.
nochange with an empty bodyThe adapter returns the matching baseline. The network status is 200.

Check encoding and content type as well as mode: an origin-side delta label can accompany full JSON. On negotiated browser deltas, compare X-QSCS-Wire-Bytes with X-QSCS-Payload-Bytes for body transfer savings. The reconstructed response includes X-QSCS-Reconstructed: 1.

Reference settings

Adjust browser memory limits

Configure the shared client before its first API use. Defaults are 2 MiB per baseline, 8 MiB total and 32 baselines:

Browser JavaScript — client configuration:

qscs.configure({
  maxEntryBytes: 4 * 1024 * 1024,
  maxCacheBytes: 16 * 1024 * 1024,
  maxEntries: 64
});
await qscs.ready;

Use positive integers with maxEntryBytes <= maxCacheBytes. Supported ceilings are 64 MiB per baseline, 256 MiB total and 1,024 entries. These browser budgets are separate from node response-cache capacity. Older entries are evicted at the aggregate limit; larger ordinary responses remain full JSON.

Live subscriptions default to a 32 MiB response limit. Set maxResponseBytes in subscription options for larger reports, after testing device memory. Stream deltas currently apply to states up to 2 MiB; larger updates use full snapshots. Parsed objects, temporary buffers and decoder memory add to these payload sizes.

Standalone daemon configuration

Console-managed domains receive these policies automatically. For deployments using your own configuration tooling, configure the API origin:

[Origins]
api.example.com = 127.0.0.1:8081 Auth=identity Proxy=all Delta=all

On issuer nodes:

[Federated Identity Audiences]
api.example.com Paths=/api/reports/

On recipient nodes:

[Trusted Auth Origins]
api.example.com = app.example.com Paths=/api/reports/ CacheTTL=60s ResponseCacheTTL=until-invalidated ResponseCacheRevision=1 APIBoost=on

For a browser using standalone configuration, set the browser SDK allowlist before loading it (browser JavaScript):

window.QSCS_FEDERATED_IDENTITY_ORIGINS = ['https://api.example.com'];
  • Proxy=all controls backend fetching; Delta=all enables API delta delivery. An explicit federated cache policy can serve a response before the backend fetch.
  • CacheTTL controls identity-binding reuse, from 1 to 300 seconds. ResponseCacheTTL controls response reuse: until-invalidated, a timed value such as 3600s, or off.
  • Use APIBoost=on with ResponseCacheTTL=until-invalidated for background refresh. Set APIBoostIdleTimeout=172800s for the default 48-hour inactivity expiry (supported range: 3,600 to 31,536,000 seconds). Omit APIBoost or set it to off for ordinary response caching. Without Boost, federated response caching requires Proxy=all.
  • To invalidate standalone responses, increase ResponseCacheRevision and restart all recipient nodes with the updated configuration. Never reuse an earlier revision. Console-managed relationships maintain revisions automatically.
Need a hand with your deployment?Contact support ↗Back to top ↑