coderedcorp / coderedcorp/wagtail-cache
Cache does not work if timeout is set to None
- Dominant language
- Python
- Stars
- 90
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
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: https://github.com/coderedcorp/wagtail-cache/blob/79638e9a1c707f2d88154cd345200966e6a458e0/wagtailcache/cache.py#L299
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:
https://github.com/coderedcorp/wagtail-cache/blob/79638e9a1c707f2d88154cd345200966e6a458e0/wagtailcache/templates/wagtailcache/index.html#L28
https://github.com/coderedcorp/wagtail-cache/blob/79638e9a1c707f2d88154cd345200966e6a458e0/wagtailcache/templatetags/wagtailcache_tags.py#L13
It is of course possible to just set the timeout to an arbitrarily high value, but supporting `None` seems nicer.
Contributor guide
Assessment
This issue has not been assessed yet.