Thursday, September 15, 2011

Think Speed : mod_pagespeed for Apache

World of web is becoming faster day by day. Webmasters have been making conscious efforts to enhance website speeds even more, now that Google has even page rank linked to website speed. Sticking to efficient coding and adopting best practices has always been the steps taken by webmasters to speed up their sites. As a webhost, there are quite a lot of steps to be taken to help your webmasters in this race of website performance. Lets look at the latest in the block.


mod_pagespeed is an open-source Apache module that optimizes web pages and resources by them. It does this by re-writing the resources used, using filters that implement web performance best practices. Webmasters and web developers can use mod_pagespeed to improve the performance of their web pages when serving content with the Apache HTTP Server. The module is, for now compatible with Apache version 2.2 and is now available as a down-loadable binary for i386 and x86-64bit systems. The module has been tested in both CentOS and Ubuntu and the binary form can be used in other Debian/RPM based distros.
An open source code accessible through svn can be found here.

How it works

The module performs several optimizations on the fly, such as optimized caching, minimized client-server round-trips, minimized payload size and optimized browser rendering, and more. The end result is much higher performance for the websites which is usually to the tune of upto 100%, or in other words half the loading time.
mod_pagespeed includes several filters that optimize JavaScript, HTML and CSS style-sheets. It also includes filters for optimizing JPEG and PNG images. The filters are based on a set of best practices known to enhance web page performances.

Getting started

This part is rather easy, and shouldn’t take more than a couple of minutes, if you are familiar with Apache and its modules. Even otherwise, the installation and configuration is pretty straightforward.
The rpm package can be found here, which can be installed in servers that have Apache 2.2 installed with an rpm/deb package. The details are present in the same page.
The following link outlines compiling the module from source. If none of these work, the option of extracting the files from within the package, and loading the extension appropriately would work as well.
Once the module is installed, say with rpm/deb package, the configuration file can be found at :
Ubuntu: /etc/apache2/mods-enabled/pagespeed.conf
CentOS: /etc/httpd/conf.d/pagespeed.conf
The modules are to be loaded within this configuration, and the web-server needs to be restarted for the module to work.
Now, to enable and disable various filters, a fair understanding of each filter is mandatory. The details on filters can be found here. Additional information on configuration can be found here.