Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB supports caching?

Does CouchDB supports caching out of the box or do I have to manually have a caching proxy in front of it like Squid?

like image 379
ajsie Avatar asked Feb 10 '11 01:02

ajsie


2 Answers

Short answer: No.

Long answer: Yes?

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.

like image 61
JasonSmith Avatar answered Nov 30 '22 14:11

JasonSmith


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.

like image 25
Dominic Barnes Avatar answered Nov 30 '22 14:11

Dominic Barnes