Vagrant/VirtualBox/Apache2 Strange Cache Behaviour

Apache2vagrantvirtualbox

I'm using Vagrant to run an Ubuntu powered VirtualBox with Apache2.

The webserver, among others, serves static files from my /vagrant directory.

This works well most of the time. But when I change an image on my shared folder and reload the website, the previous version of the image is served, but it's truncated.

It works if I delete the old picture first from my shared folder, refresh the website so the picture is NOT shown, then save the new file and reload the website again.

Does anyone knew about this problem? I don't have anything special installed, just Apache 2 with mod_rewrite and PHP with Mongo, APC Plugin, MongoDB as well as nodeJS with a bunch of scripts.

Best Answer

Found the answer here:

JC,

What you're seeing is probably because the server serving the static files is using the "sendfile()" syscall, which is broken with the VirtualBox file system. You need to disable sendfile() usage in your server. For Apache:

EnableSendfile off

And for nginx: sendfile off;

Best, Mitchell

Related Topic