TSHttpTxnCacheKeyDigestGet

Synopsis

#include <ts/ts.h>
TSReturnCode TSHttpTxnCacheKeyDigestGet(TSHttpTxn txnp, char *buffer, int *length)

Description

Get the effective cache key digest (cryptographic hash) that was used for cache lookup or storage on this transaction. This is the raw hash bytes, not a hex or base64 encoding.

The digest size depends on the build configuration: 16 bytes for MD5 (default) or 32 bytes for SHA-256 (FIPS mode). A 32-byte buffer is sufficient for either mode:

char digest[32];
int  digest_len = sizeof(digest);
if (TSHttpTxnCacheKeyDigestGet(txnp, digest, &digest_len) == TS_SUCCESS) {
  // digest_len contains the actual number of bytes written
}

Pass nullptr for buffer to query the digest size without copying.

Returns TS_SUCCESS if a cache key was computed for the transaction. Returns TS_ERROR if no cache lookup was performed, or if buffer is non-null and *length is smaller than the digest size. In all cases *length is set to the required digest size on return.

See Also

TSHttpTxnCacheLookupUrlGet()