1

I have setup a Vagrant box with Ubuntu 12.04 and Apache2 (all very vanilla, as per Vagrant's tutorial). I've been testing it for web development and I stumbled across a weird issue (not sure if bug or feature):

  • I have setup a synced folder across my machine and the VM folder. Apache has been serving the files mostly well, except (up to now) for a JSON file I'm using.
  • If I edit it locally, it seemingly syncs it to the VM folder. Both copies are the same.
  • Although, if I XHR it from the browser after modifying it, I still get the previously served version of that file.

At first, I thought the browser had it cached, but after trying with 2 different browsers (Chrome(ium) and Firefox), after clearing their respective cache, the issue remained.

I finally managed to go around it by reloading (vagrant reload) the VM.

What I was wondering is if this is a bug or a feature and how can I go around it. Is Apache configurable to not cache server side for a specific folder/file/filetype?

Joum
  • 3,189
  • 3
  • 33
  • 64
  • is the folder synched using `rsync` ? – Frederic Henri Oct 07 '15 at 09:01
  • @FrédéricHenri IDK... How can I check? – Joum Oct 07 '15 at 09:04
  • in your vagrant file you would have `type: "rsync"` or `:rsync => true` for this synced folder – Frederic Henri Oct 07 '15 at 09:13
  • There is no such line in the Vagrantfile. I've been reading the Vagrant docs about `rsync` and now it definitely seems like a feature. But shouldn't a changed file automatically be removed/updated in the server's cache? – Joum Oct 07 '15 at 09:23
  • ok and I think I completely misunderstood your question ! for Apache caching, you can check the [doc](http://httpd.apache.org/docs/2.2/en/caching.html) look in the conf if you have `mod_cache` enabled – Frederic Henri Oct 07 '15 at 11:39

2 Answers2

1

vagrant use previous setting until you provision that new setting again, so after every change in vagrant do provision to see reflected output. There is no apache2 cache problem.

For that use command

vagrant reload vmname --provision

if your vm name is default then use

vagrant reload default --provision

it will reboot vagrant vm and apply change to vm .After provision you will be able to see changes.

pl_rock
  • 14,054
  • 3
  • 30
  • 33
0

Finally figured it out. This relates to an issue that occurs with both Apache and /or Nginx: the sendfile option in server configuration.

Basically a new file wasn't being sent/updated client side even when it was changed server-side by Vagrant sync mechanism.

Check this answer for a solution: here.

Community
  • 1
  • 1
Joum
  • 3,189
  • 3
  • 33
  • 64