createCacheResponseInterceptor = globalCacheOptions => async responseParam => {
  const response = /** @type {CacheResponse} */ (responseParam);

  if (!response.request) {
    throw new Error('Missing request in response');
  }

  const { requestIdFunction, methods, contentTypes, maxResponseSize, maxCacheSize } =
    extendCacheOptions({
      ...globalCacheOptions,
      ...response.request.cacheOptions,
    });

  if (!response.fromCache && isMethodSupported(methods, response.request.method)) {
    const requestId = requestIdFunction(response.request);
    const responseSize = maxCacheSize || maxResponseSize ? await getResponseSize(response) : 0;

    if (
      isCurrentSessionId(response.request.cacheSessionId) &&
      isResponseContentTypeSupported(response, contentTypes) &&
      isResponseSizeSupported(responseSize, maxResponseSize)
    ) {
      // Cache the response
      ajaxCache.set(requestId, response.clone(), responseSize);

      // Truncate the cache if needed
      if (maxCacheSize) {
        ajaxCache.truncateTo(maxCacheSize);
      }
    }

    // Mark the pending request as resolved
    pendingRequestStore.resolve(requestId);
  }

  return response;
}
Response interceptor to cache relevant requests
@param {CacheOptions} globalCacheOptions
@returns {ResponseInterceptor}