You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by garrensmith <gi...@git.apache.org> on 2016/04/07 16:07:44 UTC
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
GitHub user garrensmith opened a pull request:
https://github.com/apache/couchdb-chttpd/pull/111
Create md5 etag for _local docs
This makes a unique ETAG for _local docs, so that they are cached
correctly, and fetched again when the document changes.
fixes COUCHDB-2978
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/couchdb-chttpd local-docs-2978
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/couchdb-chttpd/pull/111.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #111
----
commit 1ca86421bafd17cc5b954d9075e3a053ea951f6a
Author: Garren Smith <ga...@gmail.com>
Date: 2016-04-07T13:47:05Z
Create md5 etag for _local docs
This makes a unique ETAG for _local docs, so that they are cached
correctly, and fetched again when the document changes.
fixes COUCHDB-2978
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by nolanlawson <gi...@git.apache.org>.
Github user nolanlawson commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206962757
I'll note that WebKit has actually fixed the bug in master, so it should appear in the next Safari release: https://bugs.webkit.org/show_bug.cgi?id=156048
In general, though, I'm still +1 on this PR because it's best to not make assumptions about subtleties of browser caching. Firefox or Chrome could change their implementation tomorrow and break in a new way. This ETag behavior LGTM.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-207003888
ah true. yes, fair. We'd like to _guarantee_ that the ETag is a digest of the response body (either directly or indirectly).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206936696
I'm ok with changing this for _local docs.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206929118
Where do we promise that ETag is the _rev value? We have X-CouchDB-NewRev when we intend to convey the new rev value, for example.
I like this change, it makes _local doc ETags work correctly. Clients can cache based on this and their cache hits will be for the correct body content (that's why rev and body are in the calculation, as both appear in the JSON response body but are stored in separate fields of #doc{}).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206947899
I guess, I figured why and how this could be explained: we don't use _rev for _local docs as they are not tracked by MVCC feature, but we still want to provide some sane token for caching and notifying the client that the content had changed. So Etag forms using the same rules as the _rev, but doc itself doesn't uses MVCC _rev feature. Sounds good for me.
+1
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206925749
I was thought that the idea is to not send Etag for _local docs at all. Now it breaks the rule that Etag for docs matches _rev field value.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206931507
@rnewson Everywhere all the time:
```
$ echo '{"foo":4}' | http put http://localhost:15984/db/test
HTTP/1.1 201 Created
Cache-Control: must-revalidate
Content-Length: 67
Content-Type: application/json
Date: Thu, 07 Apr 2016 14:13:26 GMT
Etag: "1-80d7ea9795ad67ad0e7a1e567c15314e"
Location: http://localhost:15984/db/test
Server: CouchDB/fc9acc2 (Erlang OTP/17)
X-Couch-Request-ID: 13cab4abd5
X-CouchDB-Body-Time: 0
{
"id": "test",
"ok": true,
"rev": "1-80d7ea9795ad67ad0e7a1e567c15314e"
}
```
```
$ echo '{"foo":4, "_rev": "1-ABC"}' | http put http://localhost:15984/db/test?new_edits=false
HTTP/1.1 201 Created
Cache-Control: must-revalidate
Content-Length: 38
Content-Type: application/json
Date: Thu, 07 Apr 2016 14:13:39 GMT
Etag: "1-ABC"
Location: http://localhost:15984/db/test
Server: CouchDB/fc9acc2 (Erlang OTP/17)
X-Couch-Request-ID: 2c37ce6ed3
X-CouchDB-Body-Time: 0
{
"id": "test",
"ok": true,
"rev": "1-ABC"
}
```
Also [from docs](http://docs.couchdb.org/en/latest/api/document/common.html#head--db-docid). And many entries in wiki I'm lazy to search for. That's an old feature that simplifies caching without adding some new entity to remember.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by daleharvey <gi...@git.apache.org>.
Github user daleharvey commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206997192
In CouchDB it does however you can write documents with any revision you want - https://issues.apache.org/jira/browse/COUCHDB-2764, its a bit of an edge case so I havent pushed it, but still possible
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206954383
right. the ETag is to allow correct caching, and I see no reason to make them uncacheable when we can easily mix in the body. Also, there are browsers that do caching poorly in the absence of ETag, so this should fix a bug or two.
cc @daleharvey @nolanlawson
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206941075
@rnewson @garrensmith
May I ask you about the reasons to include Etag if _local docs are not intended to be cached? Not for dispute, but to clarify that moment and know what to answer on "wtf why so inconsistent"? (:
P.S. However, with PouchDB we could say, that every web browser now is a replicator, so eventually, they'll use that feature (and that's why this whole story get started).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by daleharvey <gi...@git.apache.org>.
Github user daleharvey commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206993718
Yeh the behaviour of Etag doesnt match the couchdb semantics for `_rev` and using for the same thing causes bugs, I would really like to see this for all docs (ie if you ever match an Etag, you are guaranteed the same content) but at least having it for local docs would be nice
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206937312
@kxepal thanks for the doc link. I suggest we update to say it doesn't apply to _local docs, which nothing would usually cache, because it's only the replicator (or libraries implementing replication) that would get/put them.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206994326
@daleharvey but the _rev for regular documents mixes in the body and the attachment md5's, this is the first I'm hearing that the ETag for regular docs is wrong.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206932105
As for ` X-CouchDB-NewRev `, this only used for update functions and as a workaround the fact, that it's impossible to return a new revision for the updated doc from there.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206936711
+1
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:
https://github.com/apache/couchdb-chttpd/pull/111#issuecomment-206926271
@rnewson and I figured sending an md5 hash of the body and the revision might be better than not sending anything.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-chttpd pull request: Create md5 etag for _local docs
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/couchdb-chttpd/pull/111
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---