http.ResponseWriter and gzipResponseWrite in ServeV1Query


I’d like to ask to add the support for gzipResponseWrite for on-fly gzipping the output json.
In some situations, this helps to decrease the time needed to upload the output payload (json) to a client (a database via apache, a browser via apace or a simple js in /static/ folder of the cayley).

I have notice that the latency time (time needed to deliver the response back, I have tested libcurl ) may be twice larger than the cayley query time even for small jsons (~100 elements and each of ~ 100 bytes).

Here is a few examples of an optimization of http traffic:
and the gzipping plays the important role.

Because I transfer quite big JSONs (about 100K elements) back, I propose to introduce GzipServeV1Query utilizing gzipResponseWrite. Example of the gzipResponseWrite can be found here!topic/golang-nuts/eVnTcMwNVjM
and here

if you decide to implement gzipping, you can find additional information on the choice of the compresser: gzip or zlib, below.

  1. PHP supports both
  2. apache supports only zlib (deflate)
  3. HTTP specification supports both
    but not all browsers supports both :slight_smile:
  4. uses gzip
  5. here is an example of zlib in go
  6. In principal, zlib and gzip formats are compatible (except headers)