# Configuration

The minimum recommended settings for your config.php file:

```php
$config['speedy_enabled'] = 'yes';
$config['speedy_driver'] = 'file';
```

The following are optional:

### Optional Configuration

The following list of `$config` options are all set to the recommended values by default. You can change them based on your site's needs.

`speedy_block_bots`&#x20;

Check the user agent and prevent caching items when a bot is detected. (Default: `"no"`)

`speedy_break_async`&#x20;

Attempt to break the cache asynchronously when possible. (Default: `"no"`)

`speedy_diagnostics_enabled`

[Diagnostics](diagnostics) are enabled by default. Set this to `no` to disable diagnostics. (Default: `"yes"`)

`speedy_driver`

The default driver to use if one is not specified on the module tag. (Default: `"dummy"` Options: (`dummy|database|file|redis|static|memcache|memcached`) You can only have 1 driver set to default at a time.

`speedy_driver_fragment`

This lets you cache some pages with the static driver and cache other pages using fragments. A duel setup might look like this in your config file.

```php
$config['speedy_driver'] = 'static';
$config['speedy_driver_fragment'] = 'redis';
```

`speedy_enabled`

Set this to `no` to disable Speedy completely. (Default: `"yes"`)

`speedy_enable_refresh`&#x20;

If set to no will not attempt to refresh any of the cached items, thus no cURL requests behind the scenes to try to re-generate cached items, which can take time depending on the size of the site. (Default: `"yes"`)

`speedy_exclude_404s`&#x20;

Set this to `no` to cache pages that result in a 404 error. (Default: `"yes"`)

`speedy_ignore_action_requests`

Set this to `yes` to prevent ACT requests from being cached. This is only necessary if an `{exp:speedy:static}` or `{exp:speedy:fragment}` tag is added to something that gets parsed as a template in an Action request, which is very uncommon. (Default: `"no"`)

`speedy_ignore_post_requests`

Set this to `yes` to prevent POST requests from being cached. (Default: `"no"`)

`speedy_logged_in_only`

Prevent caching items when the visitor is logged in. (Default: `"no"`)

`speedy_logged_out_only`

Prevent caching items when the visitor is logged out. (Default: `"no"`)

`speedy_query_cache_allowlist`

Add an array of $\_GET keys that are valid when caching a static page (Default: \[]), In of version 1.2 of Speedy `speedy_query_cache_whitelist` was renamed to `speedy_query_cache_allowlist`

`speedy_refresh_curl`&#x20;

Set this to `no` to disable cURL drivers when refreshing the cache. (Default: `"yes"`)

`speedy_refresh_async`

Attempt to refresh the cache asynchronously when possible. (Default: `"yes"`)

`speedy_refresh_exec`

Set this to `no` to disable exec drivers when refreshing the cache. (Default: `"yes"`)

`speedy_refresh_interval`

The number of seconds to sleep between refreshing cache items. (Default: `0`)

`speedy_secret`

A secret passphrase used to authenticate request to ACTion urls. (Default: `""`)

`speedy_static_path`

The path to the static file cache directory. (Default: `DOC_ROOT . "/static"`)

`speedy_static_enabled`&#x20;

Set this to `yes` to enable the static file cache. (Default: `"no"`)

`speedy_static_use_html_file`

Set this to `yes` to save static cache files as `.html` files. (Default: `"no"`) By default Speedy saves the static cache files as `.php` files, with the contents of the page stored in the file, along with logic to handle redirects, CSRF tags, and custom headers. In some rare cases the encoding/escaping used to save the page contents in the `.php` file can cause parsing issues. Enabling this option will instead save the actual contents of the page as a basic `.html` file along side the `.php` file, which will still be used to handle redirects, custom headers etc. If the .html file is present, the `.php` file will use it's content instead of what is in the `.php` file.

{% hint style="warning" %}
There is a very high likelyhood the `speedy_static_use_html_file` default value will be changed to `yes` to enable the accompanying `.html` file in new installations in a future release.
{% endhint %}

`speedy_ttl`&#x20;

The default TTL in seconds to use if one is not specified on the module tag. Set this to `0` to cache items until the cache it broken. (Default: `3600`)

`speedy_disable_category_cache_breaking`

This will disable the action that will clear cached items based on category cache breaking rules when a category is saved or deleted.

`speedy_use_queue`

If the Queue module is installed, tell Speedy to queue all cache breaking and url refreshing actions. (Default `"no"`)

### Driver Configuration

Speedy has some drivers that are configurable, thus they require extra configuration. The Redis and Memcached drivers require server connections. All configurable drivers have a control panel page to manage their settings, however, you can also manage those settings in your `config.php` file. Below are examples of config file overrides for the Static and Redis drivers.

The Static driver does not have configuration, other than `speedy_static_path` and `speedy_static_enabled`, but you may choose to define some url paths that are to be ignored when caching. Note that ignores can be valid regular expressions.

The Redis driver has additional configuration to manage it's connection to the Redis server. Note that Speedy currently only supports 1 Redis server.

```php
$config['speedy_redis_settings'] = [
    'static' => 'yes',
    'servers' => [
        [
            'host' => '127.0.0.1',
            'port' => '6379',
            'timeout' => '0',
            'password' => null,
            
            // These are optinal values if you're
            // using a more advanced setup.
            'database' => '',
            'prefix' => '',
        ]
    ],
    'ignore_urls' => [
        ['url' => 'invalid/page'],
        ['url' => '^[a-z]{2}/products'],
        ['url' => '^products/.*'],
    ],
];
```

Similarly, the Memcached settings can be managed in your config file as well.

```php
$config['speedy_memcached_settings'] = [
    'persistent' => 'yes',
    'servers' => [
        [
            'host' => '127.0.0.1',
            'port' => '6379',
            'weight' => '0',
        ]
    ],
];
```

### Ignoring URLs

You can ignore URLs by not adding the `{exp:speedy:static}` tag to a template, but in the event you need it in the template for one use case, but want to exlude caching that page in a different use case where the same template is applied, you can use the following setting.

```php
$config['speedy_static_settings'] = [
    'ignore_urls' => [
        ['url' => 'invalid/page'],
        ['url' => '^[a-z]{2}/products'],
        ['url' => '^products/.*'],
    ],
];
```

You can still optionally wrap the `{exp:speedy:static}`  tag in a conditional.

```markup
{if segment_1 != "something"}
    {exp:speedy:static}
{/if}
```

### Environment Config

_Added in v1.14.0_

If you are using the `.env.php` file you can configure Redis and Memcahced using environment variables.

```bash
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_USERNAME=null
REDIS_PASSWORD=null
REDIS_DATABASE=1
```

In the control panel, prefix the variable name with a `$` to indicate to Speedy that it should load the value from the `.env.php` file if present.

This option is only available for connection settings. You can not define Ignored URLs through the environment config.

<figure><img src="https://3476660910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ly1eNBG1JvS5rivVtg3%2Fuploads%2FXPVbhIiH8J2Jc7DXhv3f%2Fspeedy-redis-env-config.png?alt=media&#x26;token=f99cb953-96f9-4067-865b-3207354c4059" alt=""><figcaption></figcaption></figure>

