Select Page

Need for Speed? mod_pagespeed from Google

Need for Speed? mod_pagespeed from Google

mod_pagespeed is the latest addition to our family of products, performing on-the-fly optimization in the Apache™ 2 HTTP Server. It provides webmasters and web developers that manage their Apache 2 configuration with technology that applies Page Speed performance best practices automatically. Webmasters can get the benefits of the optimizations without having to manually going back and fixing the performance issues that Page Speed detects.

This solution is valid if you do not want to carefully optimize your site, and it come for now at huge initial CPU costs till the cache is filled up. The load on my server has proven to be unacceptable (for me) and I was forced to switch it off. But it may work on your server depending on the page size, number of visitors. Authors are working hard and communicating a lot on the official mailing list to reduce that load and improve the code in the coming weeks

If you trust me, you can download the library module libmod_pagespeed.so for Apache 2.2

from http://drivers.waltercedric.com/

Check before installing the MD5 keys of this file

# md5sum -b mod_pagespeed.so 187995e3623a222ec5b54c331ee7ffaa *mod_pagespeed.so

If it matches, drop it into your Apache library folder /usr/lib64/apache2/

Build Apache module mod_pagespeed yourself

On my OpenSuSE system, I was forced to install first

zypper in gcc-c++

Then read  http://code.google.com/p/modpagespeed/wiki/HowToBuild

you should get after a successful build

  • ./out/Release/libmod_pagespeed.so
  • ./out/Release/install/common/pagespeed.conf

Install the module library

cp ./out/Release/libmod_pagespeed.so  /usr/lib64/apache2/mod_pagespeed.so

Configuration

After installing mod_pagespeed, it can be customized and configured by editing the Apache configuration file

/etc/apache2/conf.d/pagespeed.conf

so you can run

# cp ./out/Release/install/common/pagespeed.conf /etc/apache2/conf.d/pagespeed.conf

Create some directories

# mkdir /var/mod_pagespeed/ # mkdir /var/mod_pagespeed/cache/ # mkdir /var/mod_pagespeed/files

Has to be writtable by apache

chown -R wwwrun:www /var/mod_pagespeed/ 

and finally restart apache

 apache2ctl restart

There is a lot of available settings that are all well explained in this page http://code.google.com/speed/page-speed/docs/using_mod.html

Here is my /etc/apache2/conf.d/pagespeed.conf stripped of all comments as an example:

LoadModule pagespeed_module /usr/lib64/apache2/mod_pagespeed.so    
SetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER     
ModPagespeed on      
ModPagespeedDomain www.waltercedric.com     
ModPagespeedUrlPrefix  "http://www.waltercedric.com/mod_pagespeed/"     
ModPagespeedFileCachePath "/var/mod_pagespeed/cache/"     
ModPagespeedGeneratedFilePrefix "/var/mod_pagespeed/files/"     
ModPagespeedRewriteLevel CoreFilters     
ModPagespeedEnableFilters collapse_whitespace     
ModPagespeedEnableFilters extend_cache     
ModPagespeedEnableFilters combine_css     
ModPagespeedEnableFilters rewrite_css     
ModPagespeedEnableFilters rewrite_javascript     
ModPagespeedEnableFilters rewrite_images     
ModPagespeedEnableFilters remove_comments

# This page lets you view statistics about the mod_pagespeed module.
Order allow,deny         
# You may insert other "Allow from" lines to add hosts you want to      
# allow to look at generated statistics.  Another possibility is       
# to comment out the "Order" and "Allow" options from the config        
# file, to allow any client that can reach your server to examine        
# statistics.  This might be appropriate in an experimental setup or       
# if the Apache server is protected by a reverse proxy that will         
# filter URLs in some fashion.         
Allow from localhost         
SetHandler mod_pagespeed_statistics      

Troubleshooting

You may be forced to remove mod_deflate

You can disable mod_pagespeed by adding in the url  ?mod_page_speed=0

Some mod_pagespeed filters

Links

About The Author

I worked with various Insurances companies across Switzerland on online applications handling billion premium volumes. I love to continuously spark my creativity in many different and challenging open-source projects fueled by my great passion for innovation and blockchain technology.In my technical role as a senior software engineer and Blockchain consultant, I help to define and implement innovative solutions in the scope of both blockchain and traditional products, solutions, and services. I can support the full spectrum of software development activities, starting from analyzing ideas and business cases and up to the production deployment of the solutions.I'm the Founder and CEO of Disruptr GmbH.

Categories