HTTP Compression
HTTP Compression
The user experience is now becoming a very important factor in the e-commerce industry and faster page loads is also a key to improve it (I have heard feedbacks for faster page loads like, this site knows telepathy, you just think of it and there it is ;) you can guess the UX about it). HTTP compression enabling on hosted servers helps one to get better page speed. To understand the process in simplest terms is when a browser accepts gzip compressed content, when making request to server notifies through header that it accepts compressed content Accept-Encoding: gzip, deflate and server when sending response gzips content and adds tag to notify client Content-Encoding: gzip and so saves bandwidth and helps in faster page loads. What happens when a client does not accept compressed content? Nothing, its just normal request response.
Now how do you do it,
Nginx :
just go to ` /etc/nginx/nginx.conf ` and in http module add following lines, and reload/restart the server
Tomcat :
go to tomcat folder, open conf/server.xml
, you will find Connector
tag there, update it by adding attributes compression
, noCompressionUserAgents
, compressionMinSize
and compressableMimeType
.
we would have to add following attributes in connector tag user conf/server.xml compression=”on” compressionMinSize=”2048” (min. file size to be able to be compressed) noCompressionUserAgents=”gozilla, traviata” compressableMimeType=”text/html,text/xml” (add other MIME type as required)
sample connector tag would look like -
Add the tag and restart the server, the HTTP compression should be on now and you may test it.