Using CustomCacheKey breaks prefetching

We are using CustomCacheKey rules for API requests. To avoid spamming the backend when prefetching, we want to receive 412 for non-cached requests. xdn_prefetch=1 query parameter is sent within API requests as per documentation.
Everything works as expected when cache() is called without CustomCacheKey. — responses are cached on edge and requests with xdn_prefetch=1 are returning 200

The problem is as follows:
Our key looks like this:
key: new CustomCacheKey()
With such code, prefetch requests never return 200
I’ve tried to add .excludeQueryParameters("xdn_prefetch") manually to the cacheKey but it didn’t work.

@arturkin you will only get a 200 for cache hits.

cache misses will return a 412 for prefetch requests.

@howie.ross thanks, yes I realize that. The problem is, when using CustomCacheKey, even cached request returns 412 from prefetch. In the same time, without CusomCacheKey it returns 200

We’ve identified the issue — our service worker was striping out headers which were used for CustomCacheKeys.