Wrong page fetched after adding new Vary header
tjwalch opened this issue · 2 comments
tjwalch commented
Problem: Wrong page is fetched from cache due to headerlist being stored in wrong cache
How to reproduce:
- Create site with Wagtail cache enabled and use a separate cache instance defined by
WAGTAIL_CACHE_BACKEND
- Fill this cache up with cached pages
- Add a new Vary header
- Clear the WAGTAIL_CACHE_BACKEND cache
Expected: New Vary header is taken into consideration and different page instances are cached depending on it's value
Actual: Wagtail Cache uses Django library functions to cache the headerlist so it ends up in CACHE_MIDDLEWARE_ALIAS
("default" by default) and is not cleared by step (4) above.
Solution: In settings always make sure to explicitly set CACHE_MIDDLEWARE_ALIAS = WAGTAIL_CACHE_BACKEND
. This needs to be documented. Or implicitly set CACHE_MIDDLEWARE_ALIAS
when initializing Wagtail Cache somehow.
tjwalch commented
Unittest shows it's not correct description