← Back to team overview

dhis2-users team mailing list archive

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.


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 {
  gzip on; # Enables compression, incl Web API content-types
    "application/json;charset=utf-8" application/json
    "application/javascript;charset=utf-8" application/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

*Content-Encoding: gzip*



Lars Helge Øverland
Lead developer, DHIS 2
University of Oslo
Skype: larshelgeoverland
http://www.dhis2.org <https://www.dhis2.org>