VirtualBox 和 Nginx 提供缓存静态 JS 和 CSS 文件的速度非常慢

VirtualBox and Nginx very slowly serving cached static JS and CSS files

显然这是一个众所周知的问题:Vagrant/VirtualBox/Apache2 Strange Cache Behaviour, http://smotko.si/nginx-static-file-problem/, https://twitter.com/meinharrd/status/580098162716774400,尝试将 VirtualBox 与 Nginx 或 Apache 一起使用会出现错误行为(修改文件会更新内容,但不会更新长度,因此缩短它会导致最后变成垃圾,并使其更长,只需 t运行cates 原始长度)。解决方案始终是禁用 sendfile。

所以我禁用了 sendfile,这实际上解决了我的问题,但现在我看到所有这些静态文件每次都需要 2-3 秒才能加载。

有人见过这种行为吗?我专门将 Boot2Docker 用于 运行 Nginx 和 PHP

中的应用程序

github 上有一个关于 boot2docker 卷性能的已知问题:https://github.com/boot2docker/boot2docker/issues/593

在那一期中有一个有趣的 link 关于 A productive development environment with Docker on OS X

  • What about a shared folder in VirtualBox?

不要在 VM 中为 nginx 使用此功能,而是在主机上创建一个真正的共享资源。