# cache

Enables/disables Kirby's cache and sets cache options

****

- Read more: <https://getkirby.com/docs/guide/cache>

****

## Enabling/disabling the cache

```php
return [
  'cache' => [
    'pages' => [
      'active' => true
    ]
  ]
];
```

## Cache prefix

```php "/site/config/config.php"
return [
  'cache' => [
    'pages' => [
      'active' => true,
      'prefix' => 'example.com/pages'
    ]
  ]
];
```

You can read more about the cache prefix <a href="https://getkirby.com/docs/guide/cache#cache-drivers-and-options__cache-prefix">in the guide</a>.

## Cache driver

Set a different cache driver, default is the file driver.

```php
return [
  'cache' => [
    'pages' => [
      'active' => true,
      'type'   => 'memcached'
    ]
  ]
];
```

The following cache drivers are available:

| Cache Driver | Type | Description |
| ---- | ---- | ---- |
| FileCache | `file` | File System Cache Driver |
| ApcuCache | `apcu` | Driver for Apcu cache |
| MemCached | `memcached` | Driver for Memcached cache server |
| MemoryCache | `memory` | Driver for caching the current request in memory |
| RedisCache | `redis` | Driver for Redis cache (since v5) |
| NullCache | | Dummy Cache Driver (does not do any caching) |

You can also set a registered custom cache driver here. Check out the plugin reference <a href="https://getkirby.com/docs/reference/plugins/extensions/cache-drivers">how to create a custom cache driver</a>.

<info>
Make sure the selected cache driver is enabled on/supported by your server.
</info>

### Cache driver specific options

<since v="5.0.0">
### Redis

Redis supports multiple logical databases per Redis instance. If you store multiple caches in Redis, it is strongly recommended to choose a unique `database` number for each. This ensures that each cache gets its own independent namespace and can be flushed independently. You can read more about the concept of Redis databases in the [Redis documentation for the `SELECT` command](https://redis.io/docs/latest/commands/select/).

```php
'pages' => [
	'active'   => true,
	'type'     => 'redis',
	'host'     => '127.0.0.1', // default host address
	'port'     => 6379, // default port number
	'auth'     => ['user', 'password'], // optional
	'database' => 0 // optional, but recommended for multiple caches
]
```
</since>

## Options for other cache types

The examples above set the options for the `pages` cache. You can use the same option structure for other caches, e.g. the `uuid` cache:

```php
return [
  'cache' => [
    'uuid' => [
      'type' => 'memcached'
    ]
  ]
];
```