I have my VirtualBox installed on my Mac OS X Lion spinning a Virtual CentOS instance where my LAMP stack is running. This idea of a virtual server environment is really neat because it gives me the luxury to develop in a Linux environment close enough to my Linux setup in production. But I encountered a problem that seems simple but I couldn’t find an obvious solution – shared folder caching problem.
Every time I make changes in my JS/CSS files, it doesn’t get updated on the web page itself. I checked the file in the web server directory itself and it’s updated. But when I try to access it via its url, I couldn’t see the changes that I made. Which made me think that it has something to do with Apache and not VirtualBox.
After extensive googling and researching, I stumbled into these Apache directives:
The solution is to disable the above directives which are enabled by default. So basically we’re disabling memory mapping (EnableMMAP) which is not good when we’re working with NFS mounted files. We’re also disabling apache’s sendfile (EnableSendFile) support which basically reads static file from buffer or cache without reading the actual file itself.
Here’s how your configuration will look like:
# Some other directives here
I hope that it works for you and saved you from spending too much time finding out the solution.