Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 2.18 KB

cache.md

File metadata and controls

56 lines (38 loc) · 2.18 KB

Overview

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.

Activate

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.

Deactivate

To switch off caching features, simply unset the CACHE environment variable or set it to anything but 'enable'.

Administration

The page cache can be cleared from the Wagtail Admin by navigating to Settings > Cache, or /admin/cache/.

In development

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