PlaidWeb / Publ

Flexible publishing system for the web
http://publ.beesbuzz.biz/
MIT License
40 stars 4 forks source link

Invalidate the cache based on template file fingerprint #414

Open fluffy-critter opened 4 years ago

fluffy-critter commented 4 years ago

Expected Behavior

When a template's file fingerprint changes, the do_render cache key should change.

Current Behavior

It does not, causing old template data to persist.

Possible Solution

Include template file fingerprint as part of the cache key.

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

fluffy-critter commented 4 years ago

Note that Jinja will also need to be configured to reload templates when they change, to avoid a race condition where Publ's cache key doesn't change in lock step with Jinja's template cache. See https://stackoverflow.com/a/43606759/318857 for a possible fix.

fluffy-critter commented 4 years ago

... Except this also doesn't cover the case when the changed template is brought in via Jinja directive such as include or extends. Unclear how to actually fix this issue correctly; perhaps the ongoing guidance should be to require an app restart and possibly a cache flip whenever templates change.

fluffy-critter commented 4 years ago

How about: have Jinja reload templates when they change (per the stackoverflow link), and have a watchdog watch the template directory and bump the templating cache key whenever that changes. Now, what to bump the cache key with, to ensure that it doesn't screw up a distributed cache in a load-balanced scenario...