Issue with Networked Filesystems and Apache

I encountered an issue today when trying to serve a Javascript file through Apache. I am using a Virtual Machine (VM) for my development environment, and have shared folders set up so that it mounts my working directory from the my machine. This makes it easy for me to develop on my local machine and only run all the tools to serve websites when I need them. So what happened, is that the file would be truncated when it was trying to serve it. The point at which it was truncated seemed to be fixed, and it would only change if I modified the file. After some research I found that `sendfile` was the culprit. If you set the following directive in your apache config or your .htaccess file the problem should be solved.

EnableSendfile Off

According to the documentation, Apache tries to hand static files to the kernel’s sendfile to serve files more efficiently, but the kernel’s cache causes issues when the filesystem is mounted over the network. For more information refer to Apache’s EnableSendfile documentation.

2 Comments

  1. Thanks a lot, saved me a lot of trouble!

Trackbacks

  1. Dev Patio by Jamal Fanaian » Issue with Apache and Networked Filesystems - Web Developer in Orlando, FL

Leave a Response