Using Varnish to accelerate CouchDB

Michal Taborsky - Netretail Holding michal.taborsky at nrholding.com
Sat Nov 6 16:09:58 CET 2010


Karel,

> I am still curious if Varnish use ETag based caching at all?

Think of ETag as hash of the document. It can be used to identify 
whether the document is changed. But in order to compare the documents, 
you must check the ETag on client side against ETag on the server. So, 
in order to use ETags, Varnish would have to get the document (or at 
least it's ETag) from backend on each request.

ETags are used in client/server scenario like this:

Request 1:
client: I want /foo
server: (computes the ETag of document) here is the document, also ETag 
of /foo is bar

Request 2:
client: I want /foo, I have cached copy with ETag=bar
server: (computes ETag, it is still bar) you are OK, the document has 
not changed

-document changes-

Request 3:
client: I want /foo, I have cached copy with ETag=bar
server: (computes ETag, it is now baz) here is a new version, it has 
ETag baz

So, you see, in order to use ETags, there has to be direct communication 
between client and the server. If there is a cache in between, ETags are 
useless.

You either have to implement invalidation, or be OK with serving stale 
content. You can contact me off the list (in Czech if you wish :) ) if 
it's still not clear.

Michal

-- 
Michal Táborský
chief systems architect
Netretail Holding, B.V.
http://www.nrholding.com




More information about the varnish-misc mailing list