---
title: "cachedResponse(for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlcache/cachedresponse(for:)"
---

# cachedResponse(for:)

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

## Declaration

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

## Parameters

- `request`: The URL request whose cached response is desired.

## Mentioned in

Accessing cached data

## Return Value

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

## Discussion

Discussion If you override this method, you should also override getCachedResponse(for:completionHandler:).

## See Also

### Getting and storing cached objects

- [storeCachedResponse(_:for:)](foundation/urlcache/storecachedresponse(_:for:)-7p7bl.md)
- [getCachedResponse(for:completionHandler:)](foundation/urlcache/getcachedresponse(for:completionhandler:).md)
- [storeCachedResponse(_:for:)](foundation/urlcache/storecachedresponse(_:for:)-8uq91.md)
