Is it possible to output/debug a custom cache key?

We received this from a customer:

Morning!
is there any possibility to output/debug CustomCacheKey ? setting it like this doesn’t seem to work

setResponseHeader(
    "x-debug-cache-key",
    JSON.stringify(
      new CustomCacheKey()
        .addHeader("x-header-1")
        .addHeader("x-header-2")
        .toJSON()
    )
  );

because we get

[{"action":"add-value","value":"${req:x-header-1}"},{"action":"add-value","value":"${req:x-header-2}"}]

What you are receiving in the output is the internal representation of the custom cache key. Instead you should you try to get the values of the headers that are participating in your key:

setResponseHeader(
    "x-debug-cache-key",
    "${req:x-header-1}-${req:header-2}}",
  );

The references there are embedded values that the XDN router allows you to evaluate at runtime. You can read more about them here.

1 Like