<!--
{
  "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/URLCache/cachedResponse(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLCache(im)cachedResponseForRequest:"
  },
  "title" : "cachedResponse(for:)"
}
-->

# cachedResponse(for:)

Returns the cached URL response in the cache for the specified URL request.

```
func cachedResponse(for request: URLRequest) -> CachedURLResponse?
```

## Parameters

`request`

The URL request whose cached response is desired.

## Return Value

The cached URL response for `request`, or `nil` if no response has been cached.

## Discussion

If you override this method, you should also override [`getCachedResponse(for:completionHandler:)`](/documentation/Foundation/URLCache/getCachedResponse(for:completionHandler:)).

---

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)