I have apache/mod_dav and davfs2 all on the same host. davfs2 is used to mount what Apache is serving to the local filesystem - a sort of loopback. The purpose is that the content of the files served is dynamic and comes from a postgres database via php. In this case the file is an email footer/disclaimer that changes periodically and is read by the mail program.

This mostly works well, but when I try to cp a file from the dav directory to another part of the filesystem, it cp does not seem to trigger the 'has the file changed' check in davfs2 - it just gets the cached copy. Note the php file has not changed, only the dynamic content because something has been updated in the database.

On the other hand, if I cp again 5 seconds later, the correct file contents is copied. I've ended up with a script like this:

cp /root/pgdav/disclaimer.html /etc/postfix/disclaimer.html
sleep 5
cp /root/pgdav/disclaimer.html /etc/postfix/disclaimer.html

Caching related headers in php are set as follows:

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

I've set file_refresh 0 in davfs2.conf.

My question is: Is there some other setting I am missing to correct this behaviour?


I got my answer from the davfs2 mailing lists and thought I'd share it here:

On open davfs2 will send a conditional GET request, which depends on correct Etag values.

Once I made sure I was serving up ETag headers the problem went away.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy