我尝试了很多,但我无法缓存我在Nodejs Express上使用JADE
模板引擎构建的WebApplication。
我试过的是,
1-尝试pm2
管理器2-尝试将NODE_ENV
设置为production
3-添加缓存模块(但我不了解如何使用)
const NodeCache = require( "node-cache" );
const myCache = new NodeCache( { stdTTL: 100, checkperiod: 120 } );
但它没有缓存。
这是我的web应用程序的结果,
我需要缓存所有的静态文件。请帮帮我..谢谢
发布于 2017-10-20 05:53:41
在handler
方法中设置Cache-Control
标头。
app.get('/', function(req, res){
res.set('Cache-Control', 'max-age=31536000');
res.send('hello world');
});
不需要使用node-cache
进行客户端缓存。
https://stackoverflow.com/questions/46842771
复制