Node Express Mustache Template Caching

In my class, we are teaching the students how to use Mustache templates as the view engine for their express application. Well, one problem that I was running into was that the server needed to restart every time I modified a template.

So I googled the problem and didn’t find a solution immediately. Then, I went back to the readme and noticed this.

Properties

The return function has a cache parameter that is an LRU Cache.

So I figured that I would just try this.

And it worked! I can make changes to my mustache templates and just refresh the browser. Be sure not to do this in production. Check your environment before disabling cache.

Until next time!

Leave a Reply

Your email address will not be published. Required fields are marked *