express-handlebars icon indicating copy to clipboard operation
express-handlebars copied to clipboard

Production view cache

Open pi0neer opened this issue 6 years ago • 8 comments

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?

pi0neer avatar Aug 16 '19 09:08 pi0neer

https://github.com/ericf/express-handlebars#template-caching

Try passing cache: false as an option to the render call

UziTech avatar Aug 16 '19 13:08 UziTech

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.

pi0neer avatar Aug 20 '19 08:08 pi0neer

Hi there. I have two question regarding cache in production. Ask it here because found the question similar to myself.

  1. 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.
  2. 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"?).

mortezae avatar Jun 22 '24 01:06 mortezae

Yes caching is default behavior

UziTech avatar Jun 22 '24 01:06 UziTech

Thanks for response. So please, how to avoid page cache while still taking advantage of this default caching behavior?

mortezae avatar Jun 22 '24 20:06 mortezae

app.disable('view cache');

UziTech avatar Jun 22 '24 22:06 UziTech

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.

mortezae avatar Jun 22 '24 22:06 mortezae

See https://github.com/express-handlebars/express-handlebars?tab=readme-ov-file#template-caching

UziTech avatar Jun 23 '24 01:06 UziTech