Optimizing Web Servers for
So you’ve got a website and you are interested in providing content for wireless devices? Did you know that HTML can be compressed before it is sent to a Pocket PC, Handheld PC or Tablet PC?
Well you website can be faster for free! Microsoft has implemented the HTML 1.1 protocol including support for gzip and deflate formats in the Pocket PC 2000 and 2002, Handheld PC 2000 and desktop web browsers like Internet Explorer 4 or later. Other web browsers like Netscape Navigator 4 or later and Lynx 2.6 or later also support HTML compression. The Pocket PC and Handheld PC web browsers reports "ACCEPT_ENCODING: gzip, deflate" as does most modern browsers. So if you implement HTML compression, your website HTML will be compressed approximately 50% or more! Now that's a difference that a wireless user will recognize in the reduced cost and time of their GPRS, 1xRTT or dialup connection.
So by turning on HTML compression your website will serve up both compressed and uncompressed web pages as well as HTML 1.0 and 1.1 protocol web pages depending on what the web browser supports. This means that you do not have to worry about implementing compression on your web server and having users not be able to view your website like users of older Handheld PCs or Palm-size PCs.
Testing your Web Server and Web Browser
So to cut in half your HTML data sent and received, you need to implement gzip or deflate encoding of your content. You can test your website to see if your HTML is compressed or not by visiting http://leknor.com/code/gziped.php and entering your website’s url in. You will see a report of the headers for the HTTP connection your web server is providing. If your website does not implement gzip, a list of the improvement in speed as a percentage and in time savings that your users will see for specific connection speeds is listed if you implement gzip compression. You can also test your web browser to see if it supports compressed HTML at http://www.schroepl.net/cgi-bin/http_trace.pl.
In order to change the settings in the web server to support compression requires access to the web server’s configuration. If you do not have control over the configuration of your web server you will need to contact your ISP to change these setting. Your ISP should be interested in enabling this so your website bandwidth is reduced.
One caveat for using HTML compression is that it requires your website to use more CPU power to compress the files. So you should monitor your CPU usage before and after installing a compression solution on your web server.
Compatible with Other Optimizations
HTML compression can be implemented in addition to other optimizations on your web server. For example, you can use a PHP optimizer like Zend Optimizer or PHP Accelerator . A good description of how to optimize PHP is available - A HOWTO on Optimizing PHP. Also you can enable query caching in MySQL as well. Also, HTML compression also does not affect header compression of TCP/IP. However it does reduce the payload compression that some TCP/IP dialup connections offer. The overall size of the TCP/IP content sent in this situation is not larger than if the compression was not enabled. Also, HTML compression works fine with server side includes (SSI), PHP, XML (including RSS), FrontPage Extensions and CGI scripts.
Configuring the Apache Web Server
With Apache you can install a new Apache module called mod_gzip to do this. You will need ROOT access and have an understanding of how Linux is implemented. The latest version is 126.96.36.199a which works on Apache 1.3. The latest version allows you to compress web pages such as PHP and CGI scripts that are dynamic. A compiled version for Linux is included in the standard download. You may have to re-compile the mod_gzip module if you receive a message warning "Loaded DSO libexec/mod_gzip.so uses plain Apache 1.3 API, this module might crash under EAPI! (please recompile it with -DEAPI)". See How to install mod_gzip on a RaQ4i guide, Installing mod_gzip on Linux server or Installing mod_gzip on Ensim for details on how to install and compile mod_gzip. Also, keep in mind that you can turn on and off mod_gzip per directory in the .htaccess file if needed for compatibility. Further, there is an option to install mod_deflate if you choose instead however I have not found it as common as mod_gzip.
Configuring Microsoft Internet Information Server
By default, Microsoft has not enabled compression of HTML in Internet Information Server (IIS). Microsoft does offer an option to enable deflate or gzip compression in the latest versions of IIS. Compression uses more CPU so Microsoft recommends benchmarking your system's performance before and after enabling compression. Microsoft has made the implementation of compression very easy for webmasters. Webmasters should be aware that Microsoft chose to only support compression of static files and program files. For IIS 4.0/5.0 you can purchase a 3rd party application to compress files called Pipeboost. With IIS 5, Microsoft has documentation available to explain how to enable the compression. This is also implemented in the new Windows 2003 server. Microsoft has documentation available to explain how to enable this per website.
I am using mod_gzip for my webservers for pocketpcfaq.com and TabletPCTalk.com and it works well. So once you have implemented compression for your website your users will have an even better experience with low speed connections like wireless or dialup. I can’t imagine a wireless Pocket PC or mobile website without it!