Does CouchDB supports caching out of the box or do I have to manually have a caching proxy in front of it like Squid?
The whole philosophy of CouchDB is to think about everything that might be queried later, compute it now (when it's convenient), and store the result in an index. All data access from CouchdB comes from scanning one of these indexes, which is very fast and tends to take roughly the same amount of time regardless of the amount of data (logarithmic time actually.)
Furthermore, CouchDB does not use much memory, because it expects the operating system to cache its disk operations. The filesystem cache provides huge a huge performance benefit.
Finally, CouchDB supports all the web standards for caching, so browsers and ISPs often cache parts of it without anybody doing anything special.
I suppose my point is that for high read load, CouchDB often does not need a cache. However, no, there is no out-of-the-box cache feature. One reason CouchDB uses HTTP is to allow people to use standard tools to solve their problems. Many people do use caching web proxies in front of CouchDB in production.
It supports a form of caching via ETags. (an HTTP caching mechanism)
The ETag is the same as the documents _rev
number. You can send an If-None-Match
header along with your GET
request. If there is a new version, the server will send it. Otherwise, it sends back a 300 Not Modified
header, letting you know that you can keep using the revision you already have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With