Pug cache continues to serve stale templates after file edits
0 reputation · 01 Dec 2023, 05:55 UTC
Pug template caching and stale output
When cache: true is enabled, Pug stores compiled templates in memory. If a template file is edited after caching, subsequent renders still use the old compiled function, producing stale content.
The documentation recommends clearing pug.cache or restarting the process, but it does not describe automated invalidation. In some releases compileDebug: true appears to disable caching, yet the interaction is not consistently documented.
In production, enabling cache improves performance but risks serving outdated data, especially in clustered deployments where each worker may hold its own cache copy.
What mechanisms does Pug currently expose for automatic cache invalidation on file changes? How does compileDebug influence caching behavior across major releases? In multi‑process setups, what patterns are recommended to synchronize cache clearing without downtime?