Using CouchDB to serve HTML Using CouchDB to serve HTML json json

Using CouchDB to serve HTML


There is a simple answer: store static HTML as attachments to CouchDB documents. That way you can serve the HTML directly from the CouchDB.

There is a command-line tool to help you do this, called CouchApp

The book Mikeal linked to also has a chapter (Managing Design Documents) on how to use CouchApp to do this.


3) you can use CouchDB shows to generate HTML (or any content type)


There are huge advantages to having CouchDB serve/generate your HTML.

For one thing, the pages (which are HTTP resources) are tied to the data or to the queries on the data and CouchDB knows when to update the etag when the page has changed. This means that if you stick nginx in front of CouchDB and say "cache stuff" you get all the free caching you would normally need to build yourself.

I would push for nginx > apache in front of CouchDB because Apache isn't all that great at handling concurrent connections and nginx + erlang (CouchDB) are great at it.

Also, you can write these views in JavaScript which are documented well in the CouchDB book http://books.couchdb.org/relax/ or in Python using my view server http://github.com/mikeal/couchdb-pythonviews which isn't really documented at all yet but I'll be getting to it soon :)

I hope that view servers in other languages start implementing the new features in the view server protocol as well so that anyone can write standalone apps in CouchDB.