coderedcorp/wagtail-cache

Wrong page fetched after adding new Vary header

tjwalch opened this issue · 2 comments

Problem: Wrong page is fetched from cache due to headerlist being stored in wrong cache

How to reproduce:

  1. Create site with Wagtail cache enabled and use a separate cache instance defined by WAGTAIL_CACHE_BACKEND
  2. Fill this cache up with cached pages
  3. Add a new Vary header
  4. 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.

Unittest shows it's not correct description

@tjwalch I'm assuming you closed this because it is not an issue? If it was closed in error, can you please post a code sample recreating the problem? This would be a bad bug if it can be reliably repeated.