Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Overview

Sunbird APIs are consumed via mobile app as well as web application, where in even web-application can be loaded from mobile or tabs. Most of the api is based on exchange of request/response in json format. Motivation is to reduce the size of responses so that responses are delivered faster even on devices with slower connections.


Solution

Sunbird platform provides the api end-point over play2 framework server. It provides us the way to configure compression through notion of web-filters.


Functional:

  1. We will enable the gzip compression in our play server configuration.
  2. If user sends request header "Accept-Encoding": with one of the values as gzip, api will respond with compressed response, if it is configured to return compressed response.
  3. We will be compressing all response of type application/json by default.


Technical Solution

  1. We can provide a web-filter, for Gzip compression by configuring play.filters.gzip.GzipFilter.
  2. During object constructor,we can further customize it to perform the encryption based on parameters available in request/response object.
  3. We need to return GzipFilter object as one of the values in array returned fromĀ filters function, from the class that implements HttpFilters.

Note: We would only apply compression, if Accept-Encoding header is passed and

Advantages:

1. Response size will be considerably smaller and will use less band-width.




  • No labels