This blog is outdated. Check out my website at http://cem.re or my work blog at http://cem.re/tumblr.

can't use it

a blog by Cemre Güngör

How to fix the caching problems with VirtualBox folder sharing + Apache

We are using a common VirtualBox image for the development of our graduation project. The files reside in our own computer, so the virtual instance only runs the Apache, which pulls the files from our computer and executes them. So for Apache, the files it serves appear to be mounted with NFS (that’s the way virtual systems represent folder sharing)

While a brilliant idea, this led to very strange caching problems. For one, the CSS files I was writing weren’t getting updated. If I put a lot of stuff in a CSS file which is already cached, it would spit out other PHP code in our project!

A few days of confusion and a fellow blogger has the result. So go to the configuration file of your Apache instance in the virtual image and add these two bold lines.

<Directory “/var/www/public_html/”>
Options Indexes FollowSymLinks ExecCGI MultiViews
AllowOverride All
Order allow,deny
allow from all
EnableMMAP Off
EnableSendfile Off
</Directory>

This is a supposed to be a performance-improving default setting, but not very useful for development environments, and especially when the NFS-mounted files are actually on the same computer.

Comments

[...] after more than a day of frustration, I’ve finally came across this post: http://www.cantuse.it/2009/01/virtualbox-apache2-strange-caching-issues and managed to keep my [...]

Getting started with virtualisation - /pavlakis on 04/12/2009 at 20:24

This is exactly the problem we’ve been having, and your solution has ended two days of hair pulling frustration. Thanks for posting this…

Ivar on 17/07/2009 at 01:30

Thanks a lot of posting this. I had the same issue where CSS files getting served through apache after being edited on the host OS would not be current. I wget’d straight on the server to confirm it wasn’t a browser issue. Then cat the file locally and it was the updated copy.. Restarted apache and it’s still the old copy? So weird!

Anyway.. your fix worked. I put it in the tags as required.

Nathan on 19/09/2009 at 15:38

Thanks for posting! You just saved me a huge patch of my hair! :)

MikeyB on 30/09/2009 at 00:26

Thank you, thank you, thank you, thank you. I spent a ton of time setting up my server then ran into this, which seemed to have no solution, but eventually found this. Thanks for posting

RS on 15/01/2010 at 10:13