根据this question express.static每次从硬盘读取文件。我想缓存服务器中的文件,因为它们不会改变,不会有太多内存可用。如何缓存express.static在内存中提供的文件?
因此,对于如下代码:
// serve all static files from the /public folder
app.use(express.static(path.join(__dirname, 'public')))
// serve index.html for all routes
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'public/index.html'))
})
如何确保快递缓存文件通过在内存中express.static和res.sendFile服务?
你可以看到这个:[缓存静态](http://stackoverflow.com/questions/32154656/does-express-static-cache-files-in-the-memory) –
@BougarfaouiElhoucine这是我已经链接的问题。那里没有回答我的问题。 – vsjn3290ckjnaoij2jikndckjb
还有一个问题:https://stackoverflow.com/questions/35068471/serving-static-files-in-express-is-it-cached。但最重要的答案与客户端缓存有关,而不是服务器端(这是我所追求的)。 – vsjn3290ckjnaoij2jikndckjb