Google Mod_pagespeed Continued

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’

ModPagespeed 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.

  • MOD-pagespeed
  • ModPagespeed on
  • ModPagespeedUrlPrefix “”
  • ModPagespeedFileCachePath “/var/mod_pagespeed/cache/”
  • ModPagespeedGeneratedFilePrefix “/var/mod_pagespeed/files/”
  • ModPagespeedRewriteLevel CoreFilters
  • ModPagespeedRewriteLevel PassThrough
  • ModPagespeedEnableFilters add_head
  • ModPagespeedEnableFilters collapse_whitespace
  • ModPagespeedEnableFilters elide_attributes
  • ModPagespeedEnableFilters remove_comments
  • ModPagespeedEnableFilters rewrite_css
  • ModPagespeedEnableFilters rewrite_javascript
  • ModPagespeedEnableFilters move_css_to_head

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 2>&1| grep -i ‘X-Mod-Pagespeed’ X-Mod-Pagespeed:

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 2>&1| grep -q ‘404 Not Found’ wget -q -O - –save-headers http://localhost:80/mod_pagespeed_statistics | grep -q ‘resource_404_count: 1’ FAIL.

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.

  • resource_fetches: 2
  • total_page_load_ms: 0
  • page_load_count: 0
  • cache_extensions: 0
  • not_cacheable: 0
  • css_file_count_reduction: 0
  • css_filter_files_minified: 13
  • css_filter_minified_bytes_saved: 5082
  • css_filter_parse_failures: 0
  • css_elements: 0
  • image_inline: 0
  • image_rewrite_saved_bytes: 0
  • image_rewrites: 0
  • javascript_blocks_minified: 15
  • javascript_bytes_saved: 380
  • javascript_minification_failures: 0
  • javascript_total_blocks: 15
  • resource_url_domain_rejections: 0
  • url_trims: 0
  • url_trim_saved_bytes: 0
  • resource_404_count: 2
  • slurp_404_count: 0
  • serf_fetch_request_count: 0
  • serf_fetch_bytes_count: 0
  • serf_fetch_time_duration_ms: 0
  • serf_fetch_cancel_count: 0

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.

I still have some Javascript issues. Some things need further inspection because i have seen error like these coming along:

Permission denied for to call method Location.toString on .

Besides that. This morning my site was down due to Apache spitting segfaults. I disabled the ‘rewrite_javascript’ filter for now. And it seems to run a bit more stable.

[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.

comments powered by Disqus