I'm running into some funny stuff with the view cache in express/Jade. The controller fetches an article from MongoDB via Mongoose and hands it to the res.render function. However, after running for a couple of minutes Express starts serving the same compiled template for all requests to that route. This even happens to shared .jade includes that are used in various templates.
The database is fetching the correct articles and it doesn't matter if I pass some random strings to the template, I always get the same output.
This is the controller function:
exports.show = function(req, res) {
var articleId;
articleId = req.params.id;
Article.findOne({
_id: articleId
}).populate('author').exec(function(err, article) {
if (err) {
console.log(err);
} else {
res.render('articles/show', {
article: article,
articleId: article.id
});
}
});
};
And that's the route:
app.get('/articles/:id', articles.show);
The same things happen whether I'm running in production or development mode.
Has anyone run into this kind of toruble with Express/Jade?