How do I send gzipped data to CouchDB?

Starting from version 1.6.0, CouchDB can now accept processed JSON requests. I am sending a bunch of JSON files through the browser and being able to compress them will save a lot of bandwidth. How to make ajax post gzipped json docs for couchdb?

+3


source to share


1 answer


Two steps:

  • Compressing JSON files.
  • Send an AJAX request with a header Content-Encoding: gzip

    .

For the first step, you can use the JS library. A few examples:

For step 2, using XMLHttpRequest you can do



xhr.setRequestHeader("Content-Encoding", "gzip");

      

or using JQuery add

headers: {"Content-Encoding": "gzip"}

      

in the ajax settings .

0


source







All Articles