express-handlebars
express-handlebars copied to clipboard
Production view cache
I'm confused with template caching, i've disabled it with app.disable('view cache');.
In development everything is fine, but in production templates are still cached anyways. How can i disable it?
https://github.com/ericf/express-handlebars#template-caching
Try passing cache: false as an option to the render call
It doesn't seem right in my opinion. I just wanna disable it for whole app at once, instead of passing a prop to each render call, also it's really uncomfortable in case of a big app. Documentation even says that is easiest way to control template/view caching and i would like to do it so.
Hi there. I have two question regarding cache in production. Ask it here because found the question similar to myself.
- I don't want "page caching" (is it that so called "view cache"?), But I don't want templates read from disk by every request.
- I want compilation be done just once during app run time If possible. I mean templates to be half ready, to consume less cpu. I don't know whether it's the default behavior (some "implicit precompilation"?).
Yes caching is default behavior
Thanks for response. So please, how to avoid page cache while still taking advantage of this default caching behavior?
app.disable('view cache');
Yeah, but then It reads the template from disk for each request. This is a test with inotify:
morteza@pc1:~/accounting$ inotifywait views/home.hbs
Setting up watches.
Watches established.
views/home.hbs OPEN <-- here we receive a new http request
P.S. Clarification: Readme has already been read and question was regarding production mode.
See https://github.com/express-handlebars/express-handlebars?tab=readme-ov-file#template-caching