Last week i toyed with mod_pagespeed a bit. But just couldn’t get the hang of it. So the last two days permitted me to play some more with this great Apache module. Only this time i choose to build from source and ignore the binaries for a while.
For me the main problem was. As soon as i enabled the module. It was active for all sites running on this server. And that should not be a problem. But some of these sites are Wordpress monsters. That are ready to take any server down with a bit of high load.
So after a bit of trail and error. I figured out i could just disable mod_pagespeed globally by altering the main config file. After Apache reloaded mod_pagespeed was not active for the running sites.
in /etc/apache2/mods-available/pagespeed.conf make sure ModPagespeed is set to ‘off’
So now i can simply enable settings i need on a per vhost basis. For this site end some other sites i used the following config section in my vhost.
First of we enable mod_pagespeed of course. And then we set the current domain for this instance. After that we set the file paths for the altered and cached files. And we use ‘PassThrough’ instead of ‘CoreFilters’. So we can decide our self’s what filters we will be using.
This had a much better result then my previous attempts. The server was still happily serving pages. And the load was OK. So let’s check the sites if mod_pagespeed is actually running.
$ wget -O /dev/null –server-response http://lenss.nl 2>&1| grep -i ‘X-Mod-Pagespeed’ X-Mod-Pagespeed: 0.9.0.0-172
Well that looks good. So now it’s time to do some testing. And this leaves me with a bit of a pickle. As i don’t have the required wget v 1.12 (i have a small patch for wget v1.11). Besides that i have some other problems running the tests
TEST: 404s are served and properly recorded.
wget -O /dev/null http://lenss.nl/mod_pagespeed/ic.a.bad.css 2>&1| grep -q '404 Not Found' wget -q -O - --save-headers http://localhost:80/mod_pagespeed_statistics | grep -q 'resource_404_count: 1'
This fails because the statistics page requested is not available because this site uses rewrites. And i haven’t found a way to go around this yet besides disabling them in .htaccess with mod_rewrite. So shortly disabling this made it possible to run the biggest part of the test suite without problems.
It fails on the image compression part and that’s fine. Because i will leave that for later. So let’s run the site through the pagespeed browser extension with mod_pagespeed disabled:
load time without : 2.193 firebug/pagespeed score : 68
Now the same thing but with mod_pagespeed enabled:
Load time with : 1.284 firebug/pagespeed score : 90
That looks pretty good. And the other sites i have tested preform way better with the mod_pagespeed module enabled.
Permission denied for to call method Location.toString on .
[Thu Nov 11 07:38:24 2010] [notice] child pid 23608 exit signal Segmentation fault (11)
So besides it being a beta i am pretty impressed by the current state of this module. And after running it for a couple of weeks the statistics are pretty impressive.
Manuel Lemos also wrote a nice article about mod_pagespeed which is worth reading.