Skip to content

Cache does not work if timeout is set to None #69

@gwenya

Description

@gwenya

According to the Django documentation, a value of None for the cache timeout should mean that entries in the cache never expire (see https://docs.djangoproject.com/en/5.0/ref/settings/#std-setting-CACHES-TIMEOUT).

Using this appears desirable for wagtail cache, if we use cache invalidation, since there is no reason for a page to be re-rendered every hour/day/month/year/whatever.

However, wagtail cache will just not store anything into the cache if the cache timeout is None:

There is also an exception in the admin on the cache settings page because the code for formatting the timeout in a human-readable way cannot deal with None-values:

{% trans "Cached pages are automatically refreshed every" %} <b>{% cache_timeout %}</b>.<br>

def seconds_to_readable(seconds: int) -> str:

It is of course possible to just set the timeout to an arbitrarily high value, but supporting None seems nicer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions