...
- We can provide a web-filter, for Gzip compression by configuring play.filters.gzip.GzipFilter.
- During object constructor,we can further customize it to perform the encryption based on parameters available in request/response object.
- We will only compress the data if response size is greater than configured threshold. Default will be provided, which can be over-ridden by user through updating the environment variable.
- Variable name will be sunbird_gzip_encryption_threshold
- We need to return GzipFilter object as one of the values in array returned fromĀ filters function, from the class that implements HttpFilters.
...
public class Filters implements HttpFilters {
@Inject
GzipFilter gzipFilter;
public EssentialFilter[] filters() {
return new EssentialFilter[] { gzipFilter };
}
}
We can also pass a function - while constructing gzipFilter, to tweak when to compress the data based on request/response parameter.
(RequestHeader req, ResponseHeader resp) -> {
return (resp.headers().get("Content-Length") > configuredLimit*1000);
}
Advantages:
1. Response size will be considerably smaller and will use less band-width.
...