---
title: "storeCachedResponse(_:for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlcache/storecachedresponse(_:for:)-8uq91"
---

# storeCachedResponse(_:for:)

Stores a cached URL response for a specified data task.

## Declaration

```swift
func storeCachedResponse(_ cachedResponse: CachedURLResponse, for dataTask: URLSessionDataTask)
```

## Parameters

- `cachedResponse`: The cached URL response to store for this data task.
- `dataTask`: The data task whose response is to be cached.

## See Also

### Getting and storing cached objects

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