Powered by Syntax Highlighter scripts!

GZip encryption changes for json content

Enabling GZIP encryption for Jersey Resource classes


 Jersey REST Service
 com.sun.jersey.spi.container.servlet.ServletContainer
 
  com.sun.jersey.config.property.packages
  com.mypackage1.resource;com.mypackage2.resource.provider
 
 
  com.sun.jersey.api.json.POJOMappingFeature
  true
 
 
  com.sun.jersey.spi.container.ContainerResponseFilters
  com.sun.jersey.api.container.filter.GZIPContentEncodingFilter
 
 1

Installing apache webserver locally and enabling gzip compression for json response on ajax calls

Tried installing the apache web server in my laptop,
First used the mod_jk connector to connect to local tomcat. (ref to link)
Then disabled the mod_jk connector and switched to use the mod_proxy connector to connect to local tomcat. (ref to link)

Goal of installing apache http server locally is to enable gzip compression for the site content.

Enabled compression in tomcat directly using the connector syntax below,

 Jersey REST Service
 com.sun.jersey.spi.container.servlet.ServletContainer
 
  com.sun.jersey.config.property.packages
  com.mypackage1.resource;com.mypackage2.resource.provider
 
 
  com.sun.jersey.api.json.POJOMappingFeature
  true
 
 
  com.sun.jersey.spi.container.ContainerResponseFilters
  com.sun.jersey.api.container.filter.GZIPContentEncodingFilter
 
 1


This worked fine as long as we use the port 8080, once we have the web server listening on port 80 infront of tomcat, the gzip compression is not enabled.
To get the gzip enabled on apache http server, added the line below to httpd-vhosts.conf file

AddOutputFilterByType DEFLATE text/html application/json text/plain text/xml text/javascript text/json text/x-js application/x-javascript application/javascript

This however is working for compression the response JSON for some ajax calls and not working for some ajax calls.