4 ms·
One note about sendfile - if you are using VirtualBox and serving files out of a shared folder with nginx (or I assume Apache) you'll need to disable it or you
by dugmartin 12y ago
One note about sendfile - if you are using VirtualBox and serving files out of a shared folder with nginx (or I assume Apache) you'll need to disable it or you won't see any updates you do to files once the first version is sent.
- dirtyaura 12y agoThis VirtualBox bug was the reason that I started reading more about sendfile and encountered this article about nginx optimizations. The bug actually causes really weird behavior, in which extra bytes are added at the end of the file.
- defen 12y agoIt doesn't really add extra bytes - it "remembers" the original size of the file. So if you update the file to be larger, you only get the first N bytes. If you update it to be smaller, you get the full file + zero bytes at the end to fill out the remainder. If you can't turn off sendfile for some reason, the workaround is to delete the file every time before saving it.
- dirtyaura 12y agoThanks, enlightening. And is this because due to some implementation difficulties for sendfile when using shared file system between the box and the host machine?
- lsaferite 12y agoI JUST ran into this issue this weekend! Glad to know I'm not going insane. Do you have any links specifically discussing the issue?
- dirtyaura 12y agoYes, this StackOverflow answer solved the mystery for me http://stackoverflow.com/questions/12719859/syntaxerror-unexpected-token-illegal/23487194#23487194 http://stackoverflow.com/questions/12719859/syntaxerror-unex... I then found out that it is actually mentioned in the Vagrant docs also: https://docs.vagrantup.com/v2/synced-folders/virtualbox.html https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
- falcolas 12y agohttps://www.virtualbox.org/ticket/9069 https://www.virtualbox.org/ticket/9069 Google for 'virtualbox sendfile' and there's a lot of discussion. Worth noting, and this bit me recently, Go's http file handler also uses sendfile beneath the covers.
- developer1 12y agoHaha omg this issue. I came across this about a year ago, and it took forever to diagnose the problem. Who would think to look for a specific declaration in the web server config? I thought for the longest time it was a problem with my host<->guest mount. Glad to see other people suffering similarly :p
- jonesetc 12y agoNot only that, but using an nginx container on OSX with boot2docker (VirtualBox based) was actually just causing all of the static files being served to be truncated. I spent a solid day tracking that down.
- ktsmith 12y agoThis occurred with VMWare Fusion 6 as well.