简体   繁体   English

Windows上的Node.js + Express.js:静态文件等待最多两分钟?

[英]Node.js + Express.js on Windows: Static files pending for up to two minutes?

I'm having an issue on my Windows environment with Node.Js/Express.js whereby static JS files can be marked as 'pending' in the browser (with caching disabled) for up to two minutes, after which they seem to download fine. 我在我的Windows环境中遇到Node.Js / Express.js的问题,静态JS文件可以在浏览器中标记为“待定”(禁用缓存)最多两分钟,之后它们似乎下载得很好。 This usually happens after a few refreshes. 这通常在几次刷新后发生。

There aren't any errors shown, so I'm not sure how to investigate further. 没有显示任何错误,所以我不确定如何进一步调查。 The same code runs fine on a Mac OSX environment. 相同的代码在Mac OSX环境中运行良好。

Node version is v0.10.31, Express is 4.8.5. 节点版本为v0.10.31,Express为4.8.5。

Code for static file is: 静态文件的代码是:

app.use(express.static(path.join(__dirname, 'public')));

Chrome DevTools shows: Chrome DevTools显示:

Chrome DevTools截图

I had the same problem. 我有同样的问题。 The solution for me was to set the resave property of express-session to false. 我的解决方案是将express-session的resave属性设置为false。

app.use(session({ resave : false, ... }));

My configuration: node v0.10.31, express v4.9.0, express-session v1.8.1 我的配置:node v0.10.31,express v4.9.0,express-session v1.8.1

As session storage I use connect-mongo v0.4.1. 作为会话存储,我使用connect-mongo v0.4.1。

Hope this helps you. 希望这对你有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM