function canCacheResponse (cacheType, statusCode, resHeaders, cacheControlDirectives) {
  if (statusCode !== 200 && statusCode !== 307) {
    return false
  }

  if (cacheControlDirectives['no-store']) {
    return false
  }

  if (cacheType === 'shared' && cacheControlDirectives.private === true) {
    return false
  }

  // https://www.rfc-editor.org/rfc/rfc9111.html#section-4.1-5
  if (resHeaders.vary?.includes('*')) {
    return false
  }

  // https://www.rfc-editor.org/rfc/rfc9111.html#name-storing-responses-to-authen
  if (resHeaders.authorization) {
    if (!cacheControlDirectives.public || typeof resHeaders.authorization !== 'string') {
      return false
    }

    if (
      Array.isArray(cacheControlDirectives['no-cache']) &&
      cacheControlDirectives['no-cache'].includes('authorization')
    ) {
      return false
    }

    if (
      Array.isArray(cacheControlDirectives['private']) &&
      cacheControlDirectives['private'].includes('authorization')
    ) {
      return false
    }
  }

  return true
}
@see https://www.rfc-editor.org/rfc/rfc9111.html#name-storing-responses-to-authen

@param {import('../../types/cache-interceptor.d.ts').default.CacheOptions['type']} cacheType
@param {number} statusCode
@param {import('../../types/header.d.ts').IncomingHttpHeaders} resHeaders
@param {import('../../types/cache-interceptor.d.ts').default.CacheControlDirectives} cacheControlDirectives