<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Tor",
  "identifier" : "/documentation/Tor/TorConfiguration/cacheDirectory",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Tor"
    ],
    "preciseIdentifier" : "s:3Tor0A13ConfigurationV14cacheDirectorySSSgvp"
  },
  "title" : "cacheDirectory"
}
-->

# cacheDirectory

Optional separate path for cached consensus and descriptor files.

```
var cacheDirectory: String?
```

## Discussion

Maps to torrc `CacheDirectory` (tor.1.txt). When set, Tor stores
`cached-certs`, `cached-microdesc-consensus`, and related files
here instead of under [`dataDirectory`](/documentation/Tor/TorConfiguration/dataDirectory), allowing the consensus
cache to outlive an ephemeral data directory.

- Performance: reusing a warm cache across runs drops cold-boot
  bootstrap time from ~30–60 seconds to ~5–10 seconds. For CI and
  interactive apps this is the single most impactful optimisation.

> Important: The cache directory is **never** deleted by
> ``doc://Tor/documentation/Tor/TorClient/stop()``, even when ``doc://Tor/documentation/Tor/TorConfiguration/ownsDataDirectory`` is `true`.
> Manage its lifecycle at the application layer.