I am writing a REST service where I am sending a JSON response of size around 3MB. Application is developed using Scalatra Framework and running on Tomcat server. As data is big of size, I want to zip the content before sending over the network to browser client.
To compress the response, I have added below code in tomcat server.xml file:
<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
compression="on"
compressionMinSize="100"
noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml,text/json,text/javascript,text/css,text/plain, application/javascript,application/xml,application/xml+xhtml,application/json"/>
But I didn't find any different in the content transferred before and after adding the above configuration. It is adding content-encoding header Content-Encoding:gzip. It didn't solve my actual goal.
To test whether this configuration is really working or not, I have copied JSON file into server and tried to access that file. It is being received as small compressed file in the client side.
Seems I am missing some configuration to add to make HTTP JSON response as zipped one. Can someone help me to solve this problem?