gpt4 book ai didi

caching - 如何在 Express - Node.js 上激活缓存?

转载 作者:搜寻专家 更新时间:2023-10-31 22:18:27 25 4
gpt4 key购买 nike

如何激活 Express 上的缓存以快速提供页面?

谢谢

最佳答案

您应该只在生产中启用缓存:

app.configure('production', function(){
var oneYear = 31557600000;
app.use(express.static(__dirname + '/public', { maxAge: oneYear }));
app.use(express.errorHandler());
});

此外,您最好使用 CDN 或 Nginx 来托管静态文件。很多 CDN 都没有那么贵,我什至在 http://www.coralcdn.org/ 找到了这个免费的 CDN。感谢 stackoverflow.com。根据this blog post Nginx even has memcached使您的网站速度极快

关于caching - 如何在 Express - Node.js 上激活缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6573315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com