How to detect responses to prefetch requests?

When listening to the turbo:before-fetch-response event, how can one detect if the response is to a prefetch request, or the result of an actual user click?

Context: I’m trying to write centralized error handling code which displays a well-formatted error to the end-user in case the server responds with a 400 (or 500) to a user-initiated request, and NOT a prefetch request.

Follow-up question – if I solve this, I reckon I will hit Access to the response body on turbo:before-fetch-response next

I have figured out a workaround for this but run into a new problem.

Workaround: Wrote. middleware to echo back the x-sec-purpose request header as a response header, which is then available in the fetchResponse.response.headers object

New problem: The pre-fetched 400 response is being cached (along with the x-sec-purpose header!) and if the user click ends-up fetching the cached response, there is no way to differentiate whether the response is coming from the cache, or as a result of an actual network request.