Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.61 KB

cache.md

File metadata and controls

43 lines (29 loc) · 1.61 KB

Overview

The page cache is provided by Wagtail Cache and is not enabled, by default. This guide leans towards 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_BACKEND: The class that will handle the caching e.g. 'django_redis.cache.RedisCache'.
  • CACHE_LOCATION: The URL of your Redis server / cluster e.g. redis://your-redis:6379.
  • CACHE_TIMEOUT: Number of seconds until a cached entry is considered stale e.g. 300 for five minutes.

These environment variables will be used to set cache arguments in the app's Django settings.

Deactivate

To switch off all caching features, it is sufficient to simply unset the CACHE_BACKEND environment variable.

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_BACKEND: django_redis.cache.RedisCache
      CACHE_LOCATION: 'redis://cache:6379'
      CACHE_TIMEOUT: '300'
    depends_on:
      - cache
  cache:
    image: redis