---
title: "init(memoryCapacity:diskCapacity:directory:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/urlcache/init(memorycapacity:diskcapacity:directory:)"
---

# init(memoryCapacity:diskCapacity:directory:)

Creates a URL cache object with the specified memory and disk capacities, in the specified directory.

## Declaration

```swift
convenience init(memoryCapacity: Int, diskCapacity: Int, directory: URL? = nil)
```

## Parameters

- `memoryCapacity`: The memory capacity of the cache, in bytes.
- `diskCapacity`: The disk capacity of the cache, in bytes.
- `directory`: The path to an on-disk directory, where the system stores the on-disk cache. If directory is nil, the cache uses a default directory.

## Discussion

Discussion A disk cache measured in the tens of megabytes is acceptable in most cases.

## See Also

### Creating a new cache object

- [init(memoryCapacity:diskCapacity:diskPath:)](foundation/urlcache/init(memorycapacity:diskcapacity:diskpath:).md)
