I'm using Express JS together with Twing (node.js implementation of Twig template engine) and created a template file (index.twig.html). I'm trying to update the template without stoping and starting node.js over and over again, but it seems to be impossible.
According to
https://nightlycommit.github.io/twing/api.html
I can set cache
to false and auto_reload
to true, so that it enables templates to be recompiled whenever their content changes instead of fetching them from the cache.
const express = require('express');
const { TwingEnvironment, TwingLoaderFilesystem } = require('twing');
let loader = new TwingLoaderFilesystem('./templates');
let twing = new TwingEnvironment(loader, { // https://nightlycommit.github.io/twing/api.html
debug: true,
cache: false,
auto_reload: true, //for debugging
});
const app = express();
const port = 3000;
app.use('/public', express.static('./public'));
app.get('/', (req, res) => {
twing.render('index.twig.html', req.params).then((output) => {
res.end(output);
});
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
I also thought of disabling the cache of Express JS itself with the tips from this topic: How to disable webpage caching in ExpressJS + NodeJS?
Didn't help either. However, looking at the console of my browser, the HTTP response code says 200
, so I don't think Express JS is the issue.