<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLProtocol/requestIsCacheEquivalent(_:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLProtocol(cm)requestIsCacheEquivalent:toRequest:"
  },
  "title" : "requestIsCacheEquivalent(_:to:)"
}
-->

# requestIsCacheEquivalent(_:to:)

A Boolean value indicating whether two requests are equivalent for cache purposes.

```
class func requestIsCacheEquivalent(_ a: URLRequest, to b: URLRequest) -> Bool
```

## Parameters

`a`

The request to compare with `bRequest`.

`b`

The request to compare with `aRequest`.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if `aRequest` and `bRequest` are equivalent for cache purposes, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

Requests are considered equivalent for cache purposes if and only if they would be handled by the same protocol and that protocol declares them equivalent after performing implementation-specific checks.

The [`URLProtocol`](/documentation/Foundation/URLProtocol) implementation of this method compares the URLs of the requests to determine if the requests should be considered equivalent. Subclasses can override this method to provide protocol-specific comparisons.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)