3

I'm using WebDav to put metadata on the files and folders of a server, along with a cache to avoid unnecessary requests to the server, based on the ETag property of the files.

Basically, I send a HEAD request and check whether the ETag matches the one I have in local. If it doesn't, then I send a larger, slower PROPFIND method to retrieve the other properties.

I built this cache on the idea that the ETag was changed every time the file was modified, including when metadata were modified, added or deleted.

However, I've recently discovered that it is not the case :

Because clients may be forced to prompt users or throw away changed content if the ETag changes, a WebDAV server should not change the ETag (or the Last-Modified time) for a resource that has an unchanged body and location. The ETag represents the state of the body or contents of the resource. There is no similar way to tell if properties have changed.

(RFC 4918, http://www.webdav.org/specs/rfc4918.html#etag, emphasis mine)

Since invalidating the cache whenever properties are changed is important to me, I was wondering: is there a way to manually instruct the web server to renew the ETag ?

Timst
  • 930
  • 1
  • 11
  • 26

1 Answers1

2

There are a couple different options. If the etag is generated based on the content (a bad idea), then it's more difficult. In our solution, we generated a different tag (a ptag) that we updated when properties changed, and you could query it with a PROPFIND, and we returned it as an X-PTag header on the response. If the etag is generated randomly on a PUT, then you could PUT the same data again, and it would give you a new etag.

Kylar
  • 8,876
  • 8
  • 41
  • 75