Enable gzip in Tomcat and WAMP
gzip is the process of compressing of content by server before sending to the web browser. The web browser then decompress the content and renders the page. The advantage of having gzip is reduced website load time and good user experience.
Note that gzip is not exactly same as DEFLATE as gzip involves extra processing in terms of check-sum and addition of header and footer. This extra processing is required as it acts as signature. Not all servers support DEFLATE out of the box but almost all servers support gzip compression. You may need to enable gzip by going to the configuration of server.
Here I will show how to enable gzip on famous servers viz. Tomcat and WAMP. While Tomcat is used for Java web applications, WAMP for PHP applications.
How to configure gzip on Tomcat
1) Go to $TOMCAT_HOME/conf and edit server.xml
2) Edit the HTTP connector as show in the following snippet:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" compression = "on" compressableMimeType="text/html,text/xml,text/plain" compressionMinSize="2048"/>
You may want to change the value of compression attribute in above code from on to force to ensure that gzip content is always served. The value on causes only text data to be compressed.
3) Restart tomcat and check HTTP headers for web application.
How to configure gzip on WAMP
1) Enable “headers_module” and “deflate_module” from WAMP tray configuration as shown below:
2) Open httpd.conf file and add the following code at the end of file:
3) Restart WAMP server