Thursday, March 3, 2016

Optimize Network performance with Gzip compression

Below is how it normally works 

1. The browser sends a header telling the server it accepts compressed content (gzip and deflate are two compression schemes): Accept-Encoding: gzip, deflate
2. The server sends a response if the content is actually compressed: Content-Encoding: gzip

If the server doesn’t send the content-encoding response header, it means the file is not compressed (the default on many servers). The “Accept-encoding” header is just a request by the browser, not a demand. If the server doesn’t want to send back compressed content, the browser has to make do with the heavy regular version.

Now there is also work to set this up in the server 

On IIS, link here gives steps to enable compression. https://technet.microsoft.com/en-us/library/cc771003(WS.10).aspx It allows compression of contents which are static, dynamic or both
On Apache server, http://httpd.apache.org/docs/2.0/mod/mod_deflate.html this link gives instruction to enable compression. 

mod_deflate is easier to set up and is standard.
mod_gzip seems more powerful: you can pre-compress content.

Below are some ways to test if the compression is enabled 

Online: Use the online gzip test to check whether your page is compressed. (http://www.gidnetwork.com/tools/gzip-test.php)
In your browser: Use Web Developer Toolbar > Information > View Document Size (like I did for Yahoo, above) to see whether the page is compressed.
View the headers: Use Live HTTP Headers to examine the response. Look for a line that says “Content-encoding: gzip”.

references


No comments:

Post a Comment