Google’s new PageSpeed Apache Module is incredible. The number of options available to improve performance on the assets served from your web server will blow your mind. I found that the default configuration worked well, but I did decide to add a few options that weren’t part of their “core set”.
I did however hit a few snags in the installation and configuration of the module. Nothing serious, but I thought it was worth pointing them out, in case others run into the same problems.
Installation
> yum install at
Package at-… already installed and latest version
Nothing to do
This is okay, it just means that at is already installed.
> rpm -U mod-pagespeed-*.rpm
error: File not found by glob: mod-pagespeed-*.rpm
The error occurs because the -U option means upgrade. I’m not sure why Google suggests using this option in their installation docs.
The approach that works is:
> rpm -i mod-pagespeed-*.rpm
If it works, great. If not, you might get an error like this:
error: File not found by glob: mod-pagespeed-*.rpm
In this case, try installing with yum. You’ll need to setup the correct repositories first. This post has detail on setting up the repos, then installing with yum.
Configuration
At this point, if you’ve installed an Apache module before, you assume that you need to head over to your httpd.conf file and add this line:
LoadModule pagespeed_module modules/mod_pagespeed.so
The PageSpeed Module has already been added to Apache’s config, even though you don’t see a LoadModule directive.
The installation process actually created a new configuration file in your server’s conf.d directory. This file is called pagespeed.conf.
The installation actually assumes that your httpd.conf has the following directive in place:
Include conf.d/*.conf
Apache comes standard with this directive in place, but some admins and hosts remove this line for security reasons (so any script or unauthorized person can’t just place a conf file in the conf.d folder). So, keep this in mind if the module does not load automatically for you.
Oh, once your done configuring, don’t forget to restart apache!
Tips
- You may find that PageSpeed’s server-side caching is a little to strong when you are in development mode on a website. Luckily, you can turn off page speed on an individual virtual host basis, i.e.:
<VirtualHost *:80>
ServerName dev.mysite.com
DocumentRoot /var/www/html/mysite_com/devModPagespeed Off
</VirtualHost>
- If you need to make a quick change to a site that has mod_pagespeed enabled, just append
?ModPagespeed=off
to the URL. This query string parameter will cause mod_pagespeed to disable itself.
Here I have Demonstrated it with screenshots and my experiment that how this module helped me, along with the results. Hope you can adjust it in your article for better understanding for users.
Install Mod_PageSpeed on CentOS | Page Speed Optimization