sys admin tip: gzip compression for async responses

To sys admins,

I was recently made aware that nginx by default will not gzip / compress responses coming from the DHIS 2 Web API.

The reason turned out to be that DHIS 2 serves content with the charset specified as part of the content-type, e.g.

Content-type:application/json;charset=utf-8

This is not caught by the default nginx configuration so you need to explicitly define it.

This change will have a significant impact on load time and performance as static javascript, css and json Web API json responses now will be compressed before sent to the browser.

I have updated the install guide with a reasonable gzip_types value:

http://dhis2.github.io/dhis2-docs/master/en/implementer/html/ch08s04.html#d5e575

  http { gzip on; # Enables compression, incl Web API content-types gzip_types "application/json;charset=utf-8" application/json "application/javascript;charset=utf-8" application/javascript text/javascript "application/xml;charset=utf-8" application/xml text/xml "text/css;charset=utf-8" text/css "text/plain;charset=utf-8" text/plain;

You can verify that content is compressed by looking for this header in the response:

Content-Encoding: gzip

regards,

Lars

···

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org