---
title: "removeCachedResponse(for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlcache/removecachedresponse(for:)-1zwp6"
---

# removeCachedResponse(for:)

Removes the cached URL response for a specified data task.

## Declaration

```swift
func removeCachedResponse(for dataTask: URLSessionDataTask)
```

## Parameters

- `dataTask`: A task whose URL request’s corresponding cached URL response should be removed. If there is no corresponding cached URL response, no action is taken.

## See Also

### Removing cached objects

- [removeCachedResponse(for:)](foundation/urlcache/removecachedresponse(for:)-1dh89.md)
- [removeCachedResponses(since:)](foundation/urlcache/removecachedresponses(since:).md)
- [removeAllCachedResponses()](foundation/urlcache/removeallcachedresponses().md)
