Wednesday, 10 May 2017

How does Express view caching mechanism work?

Could someone please explain to me how does Express view caching mechanism work? On the Stackoverflow I've found this article with this answer.

How view caching works instead is pretty simple. If enabled, express stores compiled template in process memory and renders the cached version. This way no temporary cache files are generated and the template is retrieved quickly from memory.

So, from this point I have a few questions:

  1. What does compiled template mean? As I understand, if we have, for example, EJS layout (layout.ejs) with a few partials (sidebar.ejs, navigation.ejs, etc) included in it, the Express will compile our layout.ejs with all the partials and will store this compiled, but unrendered template in the RAM? Will this compiled template still be rendered separately for each request?
  2. What if I want to implement my own views caching mechanism or take memory-cache or express-redis-cache? Should I disable Express's default views caching mechanism? If I don't do this, I will have two view caching mechanisms. Is it good practice? To my mind, it's better to have one.


via Turak Vladyslav

No comments:

Post a Comment