Node.js + Express.js on Windows: Static files pend

2019-06-23 19:37发布

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. 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.

Node version is v0.10.31, Express is 4.8.5.

Code for static file is:

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

Chrome DevTools shows:

Chrome DevTools Screenshot

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-06-23 20:14

I had the same problem. The solution for me was to set the resave property of express-session to false.

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

My configuration: node v0.10.31, express v4.9.0, express-session v1.8.1

As session storage I use connect-mongo v0.4.1.

Hope this helps you.

查看更多
登录 后发表回答