IoGT has performance features that can be enabled when a distributed cache, like Redis, is available, including:
- A page cache, provided by Wagtail Cache.
- A cache for Wagtail image renditions
- A general-purpose 'default' cache
It is strongly recommended to use Redis as the cache backend, but it should be possible to use any cache backend supported by Django 3.1.
Set the following environment variables:
- CACHE: Set to 'enable' to activate caching
- CACHE_LOCATION: The URL of your Redis server / cluster e.g. redis://your-redis:6379.
Optionally set:
- CACHE_BACKEND: Only change this if you know what you are doing. Default: 'wagtailcache.compat_backends.django_redis.RedisCache' 3
- CACHE_KEY_PREFIX: Useful for partioning the key space if sharing a Redis instance; each IoGT instance can have a different prefix to avoid interference. Set to empty string ('') to disable prefixing. Default: random UUID
- CACHE_TIMEOUT: Number of seconds until a cached entry is considered stale. Default: '300'.
These environment variables will be used to set cache arguments in the app's Django settings.
To switch off caching features, simply unset the CACHE
environment variable or set it to anything but 'enable'.
The page cache can be cleared from the Wagtail Admin by navigating to Settings > Cache, or /admin/cache/.
Most of the time it is probably desirable to switch off any sort of caching when developing the app. To avoid inadvertently committing settings that enable the page cache, it is advisable to place page cache settings in a docker-compose.override.yml
file, if using Docker Compose.
Example Docker Compose configuration:
services:
django:
environment:
CACHE: enable
CACHE_KEY_PREFIX: ''
CACHE_LOCATION: redis://cache:6379
CACHE_TIMEOUT: '300'
depends_on:
- cache
cache:
image: redis