Skip to content

Instantly share code, notes, and snippets.

@snakevil
Last active August 29, 2015 14:04
Show Gist options
  • Save snakevil/a28e75f115cd5eb7c881 to your computer and use it in GitHub Desktop.
Save snakevil/a28e75f115cd5eb7c881 to your computer and use it in GitHub Desktop.
VirtualBox 厌恶 SENDFILE 功能

VirtualBox 厌恶 SENDFILE 功能

很长一段时间内,我的开发环境都是:VirtualBox for OS X + Debian 所组成。通过 VirtualBox Guest Additions 所提供地 Shared Folders 功能,将 OS X 中地项目目录挂载进虚拟机中。这种方式优势很突出,既保持了本地开发地便捷性,又充分利用了虚拟机沙盒模式地可塑性。

但昨天在调试 CCNR2 地页面样式时,就碰到了这样地问题——

我已经在 OS X 中修改样式文件。但 Nginx 仍然输出原来地内容,只是文件尾部多了一些意味不明的红点。

  1. Nginx 输出结果
![image](https://gist.github.com/snakevil/a28e75f115cd5eb7c881/raw/bc2535a91e2a5b421902a6659c5cc43be8d6f36a/~through-nginx.png)
  1. 实际文件内容
![image](https://gist.github.com/snakevil/a28e75f115cd5eb7c881/raw/610651b79c93bd68f0f4a02307cdd05e9fd7b9b2/~stored.png)

我以为是缓存问题,但发现 Nginx 给出地响应头信息中,Content-Length 是正确地。然而,ETag 又没有发生变化!

感谢 Olivier Chappe 地这篇文章 Disable caching when serving static files with Nginx (for development) 。很细致地记录了他遇到同样地问题时地完整解决步骤。并在最后明确给出了解决方案:

Nginx 配置中,对于 Shared Folders 功能挂载地目录,将 sendfile 功能关闭掉。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment