Skip to main content

Skip unchanged reads with conditional requests

Which Platform API reads carry an ETag, how to send it back in If-None-Match, what a 304 Not Modified means, and when a read carries no tag.

DALP caches successful responses to cacheable GET reads per caller and returns an ETag header identifying the exact response body. Send that tag back in If-None-Match on your next request for the same resource. When nothing changed, DALP returns 304 Not Modified with no body. When something changed, it returns 200 OK with the new body and a new tag.

A client that omits If-None-Match downloads the full response on every poll. To react to changes without polling, subscribe with webhooks.

Send a conditional request

Read the resource once and store the ETag header from the response. See Authentication and API keys for credentials.

curl -i "$DALP_API_URL/api/v2/tokens" \
  -H "X-Api-Key: $DALP_API_KEY"
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: private, no-cache
ETag: "84e2cdb7a166d1671bc5e2abc1e78b59777dd1f863d3c5b05d09c2dd088444c2"
Vary: Accept-Encoding, X-Participant, X-Executor, X-Custody-Account-Id, X-Chain-Id, X-Network-Id, Origin

The route supplies Content-Type and its normal JSON body, CORS handling adds Origin to Vary, and the response cache sets the caching headers. Send the tag back on your next read of the same URL and query string:

curl -i "$DALP_API_URL/api/v2/tokens" \
  -H "X-Api-Key: $DALP_API_KEY" \
  -H 'If-None-Match: "84e2cdb7a166d1671bc5e2abc1e78b59777dd1f863d3c5b05d09c2dd088444c2"'
HTTP/1.1 304 Not Modified
Cache-Control: private, no-cache
ETag: "84e2cdb7a166d1671bc5e2abc1e78b59777dd1f863d3c5b05d09c2dd088444c2"
Vary: Accept-Encoding, X-Participant, X-Executor, X-Custody-Account-Id, X-Chain-Id, X-Network-Id, Origin

A 304 Not Modified carries no body, so reuse your stored copy. Different URLs or query strings produce separate responses.

If-None-Match follows four rules:

  • Send one tag or a comma-separated list. DALP returns 304 when any listed tag matches.
  • * matches whenever the read has any current tagged response.
  • Comparison is strong, so weak tags starting with W/ never match. A proxy that weakens ETag headers forces full responses.
  • On an untagged read, DALP ignores If-None-Match and returns the normal response.

Poll with conditional requests

For a client that watches a resource, send If-None-Match on every poll and replace your stored copy only on 200:

  1. Make the first read and store the body with its ETag.
  2. On each poll, send the stored tag in If-None-Match.
  3. On 304, keep the stored body.
  4. On 200, replace the stored body and tag with the new ones.
  5. On any other status, handle the error per Errors and keep the stored pair.

On a 200 without an ETag, store the new body and drop the old tag so the next poll omits If-None-Match.

Use the SDK

The TypeScript SDK manages tags automatically. It stores up to 64 responses of at most 1 MiB each, sends If-None-Match on repeat reads of the same URL for the same organisation and participant, and turns 304 back into the stored body.

The SDK clears its cache when the organisation or X-Participant changes. If you switch identity through a separate authentication client, call dalp.conditionalRequests.clear(). See Calling routes.

What a 304 means

A 304 on a cache-generated tag means the current response body is byte-for-byte identical to the body identified by your tag. Cache tags are SHA-256 hashes of the uncompressed body, so a resource that changes and changes back produces the same tag, and Accept-Encoding does not affect it.

When an operation sets its own ETag (such as a stored record version), DALP keeps that tag instead of hashing the body and matches If-None-Match against it. Treat every tag as opaque.

Which reads carry a tag

The response cache tags a read when all of these hold:

  • The operation is a GET read and not an event stream. Writes are never cached.
  • The operation has not opted out. Reads such as custody reconciliation and deposits opt out and return no tag.
  • The request does not set live=true. On reads that declare live, live=true bypasses the cache. Do not add it to other routes because some reject unknown query parameters.
  • The response has a 2xx or 3xx status, fits in 1 MiB, and is not streamed. Errors carry no cache tag.
  • The operation does not set Cache-Control: no-store or no-cache, a cookie, or an Authorization header.
  • DALP can resolve the active participant from X-Participant, or the read returns the same result for every participant.
  • The request URL and caller identity together fit within 16 KiB.
  • Response caching is enabled (the default). Self-hosted deployments can disable it with CACHE_VERSIONED_ENABLED.

A read that skips the cache (for example, during a cache fault or failed read-your-writes catch-up) returns no cache tag. Treat an omitted ETag as a normal uncached read and store the body without a tag. Operations that set their own ETag still return it regardless of the response cache.

Browser apps can read ETag and send If-None-Match because the API allows and exposes both headers over CORS. A browser's native HTTP cache also revalidates tagged responses automatically.

Who shares a cached response

Cached responses are isolated per caller. The cache key combines the organisation, user, authentication method, platform role, organisation ownership, resolved network, participant, and X-Executor, X-Custody-Account-Id, X-Chain-Id, and X-Network-Id headers. It does not include asset roles or on-chain roles.

For participant-dependent reads, the key uses the resolved participant rather than the raw X-Participant header. Participant-independent reads (such as public configuration and enabled languages) key on the raw header without resolving the participant, unless the read writes an audit record. Keep one stored tag per caller and Vary header combination.

How fresh a cached read is

DALP invalidates cached responses when underlying data changes. By default, cached entries also expire five minutes after storage.

After you write, your subsequent reads wait up to a configurable catch-up window (60 seconds by default) so you never read stale data from before your own write. If catch-up cannot complete, the read bypasses the cache and returns no tag. Other callers see changes once invalidation runs.

Cache-Control: private, no-cache tells clients they may store the response but must revalidate with If-None-Match before reusing it.

Next steps

Was this page helpful?