Gzip Compression Wix

1Installation
4Check http headers

The vast majority of websites today use some kind ofcompression, delivering their content, as most modern browserssupport compression. Compression is useful when applied to text(html, javascript, js), as images (usually png) are alreadycompressed. The result of compression is remarkable bandwidthsaving, so the site becomes more responsive. This is also a SEOadvantage.

Compression will slightly increase CPU usage, but in most casesthis is not a problem, comparing to compression advantages.

The most common compression solution is gzip compression. Almost allweb servers support gzip compression. Nginx has built-in httpcompression. This is probably a reason why Nginx rapidly gainspopularity.

If the file doesn’t exist, or the client does not support gzip, NGINX sends the uncompressed version of the file. Note that the gzipstatic directive does not enable on-the-fly compression. It merely uses a file compressed beforehand by any compression tool. To compress content (and not only static content) at runtime, use the gzip. Website gzip compression makes it possible to reduce the file size of a web file (like HTML, PHP, CSS and Javascript files) to about 30% or less of its original size before these files get sent to the browser.

Here I describe how to setup and test gzip compression in aDebian system with Apache using Apache module mod_deflate. Mod_deflate is the Apache2 successor ofApache v1.* mod_gzip. For other popular web servers you can findinformation here: IIS, Nginx.

Installation

In latest Debian version (Debian 6 or Squeeze),mod_deflate is installed and enabled. If not:

Edit website configutation file, for example:

add the following lines:

Explanation of above Apache directives:

  • Line 1: Enable gzip compression
  • Line 2: Do not compress images
  • Line 3: Do not compress already compressed files
  • Line 4: Do not compress pdf
  • Line 6-8: Some exceptions for old browsers

That’s all. Don’t forget to restart Apache.

Gzip compression algorithm

As an alternative, you can use an .htaccess file inyour webroot directory (with the same Apache directives).

Gzip compression using PHP

Gzip compression wix file

If your site is PHP based, there is an alternative (notrecommended) method to apply gzip compression. Just makethe following changes to php.ini, save and restartApache:

Check gzip compression using mod_deflate logs

Gzip Compression Wordpress

In order mod_deflate to keep logs, add the followinglines to website configuration file (and restart Apache).

To check mod_deflate log file:

Example

Comments on above log file entries:

  • Line 1: http://www.pontikis.net (compressed html document 4468bytes, original 18229 bytes, compression ratio of 24%)
  • Line 2: relevant log for layout.css
  • Line 3: relevant log for jquery.js
  • Line 4: relevant log for http://www.pontikis.net/blog/
  • Line 5: image (people.png) was not compressed
  • Line 6: relevant log forhttp://www.pontikis.net/labs/jui_datagrid/demo/
  • Line 7: relevant log for http://www.pontikis.net/feed/ (xmldocument)

You probably need to remove logging in a production server,after you check compression results.

Check gzip compression with online tools

Suggested tools:

  • GIDzip test http://www.gidnetwork.com/tools/gzip-test.php
  • DNSqueries.com test http://www.dnsqueries.com/en/check_http_gzip.php
  • HTTP Compression Test http://www.whatsmyip.org/http-compression-test/

Check http headers

Nginx Gzip Compression

Gzip compression can be detected from http headers, looking forContent-Encoding: gzip. In this example, the pagehttp://www.pontikis.net/blog/ is examined:

Chrome developer tools

Go to http://www.pontikis.net/blog/, press CTRL+SHIFT+I (orMenu button → Tools → Developer tools) and go to Network tab

Firebug (Firefox)

Go to http://www.pontikis.net/blog/, press F12 to activateFirebug and go to Net tab

Redbot.org

Using the online tool Redbot.org

We appreciate your feedback and suggestions. Leave us a commentbelow.

Gzip Compression Wix Link

Entrepreneur Full-stack developer Founder of MediSign Ltd. I have over 15 years of professional experience designing and developing web applications. I am also very experienced in managing (web) projects.

Gzip Compression Ratio For Text

Your comments are welcome!