We have some use cases where plugins modifies cache keys, making it difficult 
to see a unique identifier for a URL. Yes, you can log the full cache-key URL 
as well, but often just getting the actual cache key hash is just as good. And 
definitely more efficient.

I’m proposing a simple API to access this out of the HttpSM. The PR also has a 
new log field to make logging this easy.

        https://github.com/apache/trafficserver/pull/13134

— Leif


/**
    Gets the effective cache key digest (cryptographic hash) that was
    used for cache lookup or storage on this transaction.  The digest
    is returned as raw bytes — 16 bytes for MD5 (default) or 32 bytes
    for SHA-256 (FIPS mode).  A buffer of at least 32 bytes is
    recommended to accommodate either configuration.

    @param[in] txnp the transaction.
    @param[out] buffer caller-provided buffer to receive the raw hash
      bytes. If @c nullptr, only @a length is set (size query).
    @param[in,out] length capacity of @a buffer in bytes on input; actual
      digest size in bytes on output.

    @return @c TS_SUCCESS if a cache key was computed for this
      transaction, @c TS_ERROR if no cache lookup was performed or if
      @a buffer is non-null and too small.
 */
TSReturnCode TSHttpTxnCacheKeyDigestGet(TSHttpTxn txnp, char *buffer, int 
*length);

Reply via email to